• dwwright
  • NEWBIE
  • 100 Points
  • Member since 2010

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 22
    Questions
  • 34
    Replies

Hi community,

 

Wondering if anyone can shed me some lights. I'm this close to bang my head against the wall.

 

On our Force.com Sites, we have a "Case Study" page which lists some PDF/Excel/Words files. These files are stored in Documents in Salesforce. We want people visit our site to download them.

 

I wrote a simple VF page to output a download link, and a controller to query the Document object. But when I click on the Download link, I get the "Authorization Required" error message. I guess this is to do with Security setting between the Documents Object and the Guest User License. I did grant the Read permission on this object but no luck.

 

Is there any way to make this work? I don't really want to use Static Resource to hold these PDF files.

 

Here is my code:

 

DocumentDownload.page

 

<apex:page controller="DocumentCon" action="{!getFile}">
<apex:outputLink value="/servlet/servlet.FileDownload?file={!doc.Id}&oid={!$Organization.Id}">
Download Now!
</apex:outputLink>
</apex:page>

 

 

DocumentCon.cls

 

public class DocumentCon {	
public Document doc {get;set;}

public PageReference getFile() {
String fileId = System.currentPageReference().getParameters().get('id');

if(fileId != null) {
doc = [SELECT Id, Name, Description, ContentType, Type, Url, BodyLength, Body
FROM Document WHERE Id = :fileId];
}
return null;
}
}

 

 

 

I am utilizing Sites and my Visualforce pages use a custom object as the standard controller with an extension for additional functionality. 

 

How do I reference fields directly on a Visualforce page? For example, I have two fields that only have id's and no input value.

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VEReq" for="test_us001vereq" />
  <apex:inputTextarea id="test_us001vereq"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VERes" for="test_us001veres" />
  <apex:inputTextarea id="test_us001veres" />
</apex:pageBlockSectionItem>

 

I want to combine the input from these two Text Area Fields into one field which does have a value, meaning upon save the concatenated (combined) value will be entered (saved) into the database. 

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001" for="test_us001" />
  <apex:inputTextArea value="{!SK__c.US001__c}" id="test_us001" />
</apex:pageBlockSectionItem>

 

What options do I have to accomplish this task. I have spent 4 days looking at the forums, code examples, etc. and can not figure out how to make this work. Any suggestions, ideas, code examples, and/or links are much appreciated. Please let me know if this is unclear and I will provide more detail.

 

Also, for anyone familiar with MS Access Databases, this would be similar to bound/unbound fields and how to reference those fields within a form via VBA etc.

We have an intermediary new lead page that takes basic fields (name, phone, email, company) and searchs showing possible duplicates. When one is not found then the user can choose to create his new lead. The lead is created with all the data the rep has already filled out, inserted and then shown to the user via a a pagereference. 

 

Is there a way to not "insert" the lead before showing it? I would like for agent's to have a chance to change some other field data before the initial insert trigger is fired. I just want to open the lead to its edit page 

I'm trying to build an inventory catalog from some data stored in a custom object in Salesforce. One of the fields on the custom object stores the Id of a document that is an externally available image.

 

I'm trying to build this catalog in a Sites page and make this image appear. I'm currently doing this:

 

 

<apex:image url="/servlet/servlet.FileDownload?file={!Inventory__c.Image_URL__c}" />

 This works fine when I'm logged into Salesforce and viewing the Visualforce page directly.

 

Once I navigate to the sites page and try to view it, nothing comes up. I'm confirmed that the image is externally available, and I've set the Sites profile to "Read" for Document objects.

 

Does anyone know how you actually take advantage of externally available images and make them VISIBLE externally?

 

I'm trying to give "apex managed sharing" a test run. I've created a custom object (in my sandbox) and I'm trying to run through how to handle creating share objects.

 

Right now, I'm getting a compile error that appears to be a syntactical error, but I can't figure it out.

 

In the documentation Here, the description of how to handle doing this is pretty clear: MyCustomObject__Share. In the example, referencing their Job__c object is done as "Job__Share".

 

My object is called RFQ. The api name is RFQ__c, so I would expect the share name to be RFQ__Share. I'm getting the error: "Invalid Type: RFQ__Share" when trying to compile my code. Here's a snippet:

 

 

/*
* Trigger to test Apex Managed Sharing
*/
trigger AssignSharing on RFQ__c (after insert) {
List<RFQ__Share> shares = new List<RFQ__Share>(); List<String> srNums = new List<String>(); Map<String, Id> userIds = new Map<String, Id>(); RFQ__Share shr = new RFQ__Share(); for(RFQ__c rfq : trigger.new) { //for each comma separated SR Num in the SR Num field, add it to //the list of relevant SR nums for(String num : rfq.Sales_Responsible_Numbers__c.split(',',0)) { srNums.add(num); } } //SR Nums now holds all the Sales Responsible numbers that apply to the //rfq's being inserted, so we can query them from the database; //next step is to iterate through all the users who will be assigned a
//sharing rule (query result)
//create a map of SR#s to Ids for quick reference later for(User u : [SELECT Id, Sales_Responsible_Number__c from User where Sales_Responsible_Number__c in :srNums]) { userIds.put(u.Sales_Responsible_Number__c, u.Id); } //userIds now maps each SR# to a user Id //for each new RFQ, assign the users that need to be given share priviledges
 for(RFQ__c rfq : trigger.new) { //for each sales responsible number for(String s :srNums) { //if this RFQ has that sales responsible number if(rfq.Sales_Responsible_Numbers__c.contains(s)) { //create a sharing rule that allows the corresponding user to be added shr.ParentId = rfq.Id; shr.AccessLevel = 'edit'; shr.UserOrGroupId = userIds.get(s); shr.RowCause = Schema.rfq__Share.RowCause.SalesResponsible__c; shr.add(shares); } }//end for loops over srNums for this rfq }//end for (trigger.new) insert shares; }//end trigger

 

(Don't make fun of my code... it's for testing, not even compiled once yet, and not made to be efficient, I just want to get it to compile)

 

 

Any insight?

I have a requirement to create a trigger that runs on the CaseComment object and does a string replacement on the contents of the comment body.

 

I need this trigger to modify CaseComments belonging to Cases of only 1 record type.

 

In order to do this, I have to check the RecordTypeId field of each CaseComment's parent Case. I'm having trouble figuring out how to do this without placing a SOQL query inside of the trigger.new for loop. I've tried two different methods:

 

   This method uses a single query to pull ALL the cases from the DB that match the RecordTypeID, then checks to see if each CaseComment matches one of those cases.

 

 

ID myCaseId = '0120000000095y7';
	//Fetch all needed Cases from the database
	List<Case> cases = [SELECT Id FROM Case WHERE RecordTypeId = :myCaseId];
	
	//For all new CaseComments,
	for(CaseComment c : trigger.new) {
		//Iterate through the cases
		for(Case c : cases) {
			//if this CaseComment matches a selected case 
			if(e.ParentID == c.Id) {
							
				//make the replacement........

 This doesn't work because I have 500+ cases and the governer limit stops me.

 

 

 

The second thing I tried to do was query the RecordTypeId of the CaseComment's parent Case directly via the relationship between them. (CaseComment.Parent.RecordTypeId)

 

        //PTI Support Case RecordTypeID
	ID myCaseId = '0120000000095y7';
	
	for(CaseComment comm : trigger.new) {

		if(comm.Parent.RecordTypeId == myCaseId) {
			//make the replacement...
		

 

 

This doesn't work because the relationship returns "null" for the RecordTypeId.

 

The trigger is running before update.

 

Does anyone have a solution to this?

I'm trying to create a page that allows my users to fill in fields, attach as many files as they want, and then submit the information, creating a new lead with all the attachments.

 

What I want to do is let the user attach files BEFORE submitting, meaning BEFORE the Lead is actually inserted into the database. To try to accomplish this, I'm creating a list of attachments in the controller and then holding the attachments there. When the user clicks "submit" I then insert the Lead and assign all of the attachments in the list to that Lead.

 

The goal here is to be able to submit the Lead and its Attachments at the same time.

 

I'm hitting the viewstate size limit (I'm growing to dislike that error very much.) Is there a way to efficiently gather attachments before inserting them into the DB? Below are my relevant code snippets:

 

 

public class newLeadExtension {

public Lead theLead;
public String theName {get; set;}
public Attachment att {get; private set;} //Holds value from inputFile
public List<Attachment> attachments {get; set;} //Holds attachments
public List<String> attachmentNames {get; set;} //Holds atachment names

//Get the lead from the standardcontroller
public newLeadExtension(ApexPages.StandardController cont) {
theLead = (Lead)cont.getRecord();
att = new Attachment();
attachmentNames = new List<String>();
attachments = new List<Attachment>();
}

public PageReference attach() {
attachments.add(att);
attachmentNames.add(att.Name);
return null;
}
}

 

Attach A File:<br/>
<apex:inputFile value="{!att.Body}" filename="{!att.Name}" />
<apex:commandButton value="Attach" action="{!attach}"/>

Attached Files:<br/>
<apex:repeat var="att" value="{!attachmentNames}" >
&nbsp;&nbsp;{!att}<br/>
</apex:repeat>

 

 

(The "submit" method isn't shown here, but it just inserts the lead, then iterates through the attachment list assigning each parent ID as the lead and inserting it)

 

Thanks for any help you can provide!

I've run into a problem with one of my visualforce pages where I'm hitting this 128k viewstate size limit--I need some pointers on how to avoid it.

 

My page is used to display forms back to my users in a PDF. I've built the forms out in HTML tables with <apex: outputfield> components to display the data. My data structure is set up so that the user creates a Master Object, and then can create and number of child objects, which are the forms. Some of the forms have over 200 fields on them, but a requirement is that the user can display ALL forms they have filled out and print them in one page.

 

To accomplish this, I have an <apex:repeat> component on my page where the repeat variable is ALL the child records to this master object. This allows me to use the standard controller for the master object, then repeat through all the child objects and display their contents. I'm severely limited right now because once I create more than 5 forms, I start getting this viewstate error. I'm not using a custom controller, so I'm not really sure what I can do on my page to decrease this size, or handle it better. Please let me know if you have a solution!

I'm receiving this error on a very large (5000+ lines) VisualForce page that is used to display forms for users to fill out. The page supports several different forms, and displays whichever form is necessary based on the name of the form to be displayed (name of the form object record).

 

I have well over 100 fields from the object on this page. I added a few more fields today, and when I try to display them in an inputField component, I'm suddenly getting the:  SObject row was retrieved via SOQL without querying the requested field error. I tried putting the field at the top of the page as an <apex:inputhidden> component, and also as an <apex:outputtext rendered="false> component as referenced in this thread:

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=19680

 

 Still, I'm getting the error message.  If I put this field on another visualforce page (much smaller with only 1 or 2 fields) it displays with no problem. is there some kind of limit to how many fields from an object are queried by the Standard Controller? If anyone knows what may be going on here, please let me know. A snippet from my page is below:

 

<apex:page id="SDQA" standardController="SDQA__c" extensions="NewSDQAExtension" showHeader="false"> <apex:form> <apex:inputHidden value="{!SDQA__c.OperatorStamp45__c}" /> ...Lots and lots of code.... <apex:inputField value="{!SDQA__c.OperatorStamp45__c}" required="true" /> </apex:form> </apex:page>

 

 

 

 

 

I'm creating an application which involves creating a Master Object (Quality Document) and than creating many child objects (SDQA) which are used as forms. I have over 100 custom 'generic' fields for the child object which I adapt to whichever type of form I need the child object to be. I need to be able to clone the master object along with all of its child objects. I've created a method in a controller which does this, and it will clone the master object, and create records for the child objects--but the problem is that the child objects are not completely cloned--only a few of the fields actually get copied over. 

 

My Controller:

public class qualityDocumentExtension { 

private Quality_Document__c QD;

ApexPages.StandardController cont;

 

//Constructor, links QD to current VF pages Quality Document record

  public qualityDocumentExtension (ApexPages.StandardController qdController) {

this.QD = (Quality_Document__c)qdController.getRecord();

cont = qdController;

}//end constructor 

 

public PageReference cloneDoc() {

Quality_Document__c newQD = QD.clone(false,true);

newQD.Name += ' (CLONE - RENAME)';

insert newQD;

 

//Iterate through attached SDQAs and create clones

List<SDQA__c> sdqas = QD.SDQAs__r;

for(SDQA__c S : sdqas) {

SDQA__c newS = S.clone(false,true);

newS.Quality_Document__c = newQD.Id;

insert newS;

}

//Navigate to view the cloned Document

PageReference theRef = new PageReference('/apex/QualityDocumentOverride?id=' + newQD.Id); theRef.setRedirect(true);

return theRef;

}//end cloneDoc method

 

 I simply call the cloneDoc() method from a commandbutton component on the Quality Document.

 

Please offer any solutions you may have =) 

 

Message Edited by dwwright on 03-29-2010 11:04 AM

I have a VF page which contains (among other things) 3 picklists which are displayed using the <apex: selectList> component. The reason I'm doing this is because I need them to be dependant picklists, so I have code in my controller which dynamically updates their values.

 

All three of these fields are required; and this page is going to be displayed to external users on Sites, so the validation needs to be user friendly. Right now I'm having issues replicating the standard validation that accompanies inputField components. I've been able to copy the style to get the red bar to appear, but that's about it. The field is set to a default value of "--None--" since giving it a null value won't let the page render. This means that even if I put required="true" the fields will always have a value by default, which isn't very useful... What I want to be able to do is have a validation rule that these fields aren't equal to "--None--" and catch the exception the page throws to display an error message at the field level. Right now that works fine, but I can only display the error as a pageMessage. Is there a way to display these messages at the field level on selectList components?

Message Edited by dwwright on 03-14-2010 01:59 PM

I have a problem where I lose standard formatting on a field inside an <apex:actionRegion>. This field has an <apex:actionSupport> component nested inside of it. If I put the actionRegion tags around the entire pageBlock, the formatting stays, but if I put it directly around the field controlling the rerendering, it loses its label and gets aligned all the way to the left. I've tried encasing the whole thing in a pageBlockSectionItem, to no avail. Does anybody know a way around this?

 

 

<apex:pageBlockSection title="Breaker Selection" collapsible="false"> <apex:actionRegion >&nbsp; <!-- "Select the Appropriate Breaker" (Picklist) /--> <apex:inputField value="{!Quality_Document__c.Breaker__c}" required="true"> <!-- When the above value changes, the entire page block is rerendered /--> <apex:actionSupport event="onchange" rerender="thePageBlock" /> </apex:inputField> </apex:actionRegion>

  ..........More Fields........

</apex:pageBlockSection>

 

 

 

 

I've written a trigger which acts on the EmailMessage object, doing a string replace on a URL in the body to make it accessible to the recipient of the e-mail. The trigger runs before insert, and originally worked fine, as the email was sent into salesforce from an external e-mail, and then forwarded.

 

I'm running into an issue now with sending e-mails from within salesforce. The same trigger will change the values in the body before inserting into the database, but NOT before sending the e-mail. Since apparently e-mails are sent from Salesforce BEFORE insertion, I can't figure out how to make any changes to an EmailMessage before it is sent. Is anybody aware of a method of doing this?

I'm setting up a "Wizard" using force.com sites. I'm implementing this with visualforce and apex.

 

The page allows a user to submit information which creates an opportunity, and then takes them to a second page that allows them to create objects for quotation which are child objects to opportunity, or attach files to the opportunity.

 

When the user finishes, they are taken to a page that displays their information back to them. I am displaying a related list of the child objects they have created, and a related list of all attachments. I also give them the ability to go back and edit the items they have entered.

 

The problem is that if a user edits an item and then returns to the confirmation page, the related list of objects and attachments does not update. New items they create dont show up, and changes they have made aren't reflected on the related list. If I click the refresh button, then the changes will be reflected, so on the database end of it, the DML is happening, but the changes are not reflected on the sites page. All of my methods setRedirect(true) before returning pageReferences. In addition, this problem does NOT happen if I access the site from within Salesforce. If I log in and view the wizard, the information refreshes with absolutely no problems, it is only when viewing it externally via sites that the issue occurs

 

I'll post my code below. Any help would be greatly appreciated.

public with sharing class TechSpecController { /*Instance Variables*/ private SDV_Tech_Specification__c spec; //SDV_Tech_Spec record referred to by the controller private ID rfqId; //Id of the parent Opportunity record for this RFQ public Attachment att {get; private set;} //Holds value from inputField public List<Attachment> attachments; //holds names of attachments //Constructor public TechSpecController(ApexPages.StandardController controller){ rfqId = ApexPages.currentPage().getParameters().get('rfq'); this.spec = (SDV_Tech_Specification__c)controller.getRecord(); this.spec.Name = 'View'; att = new Attachment(); } //Accessor method for spec variable public SDV_Tech_Specification__c getSpec(){ return spec; } //Accessor method for the attachments list //(used to display attached files) back to user public List<Attachment> getAttachments() { attachments = [select Name from Attachment where ParentId = :rfqId]; return attachments; } //Submits the request to add an attachment public PageReference attach() { try { att.ParentId = rfqId; insert att; PageReference theRef = ApexPages.currentPage(); theRef.setRedirect(true); return theRef; } catch(System.DmlException e) { PageReference theRef = ApexPages.currentPage(); theRef.setRedirect(true); return theRef; } }//end attach method //Inserts the current spec and refreshes the page to enter a new one public PageReference create(){ spec.Opportunity__c = rfqId; insert spec; PageReference theRef = new PageReference('/apex/sdvSpec?rfq=' + rfqId); theRef.setRedirect(true); return theRef; }//end create method //Inserts the current Spec and takes the user to the confirmation page public PageReference createLast(){ spec.Opportunity__c = rfqId; insert spec; //direct to confirmation page return done(); }//end createLast method //Updates the changes and returns the user to public PageReference saveChanges() { update spec; //direct to confirmation page return done(); }//end saveChanges method //Deletes this spec and takes user back to confirmation page public PageReference del() { delete spec; //direct to confirmation page return done(); }//end del method //Takes user back to the confirmation page public PageReference done() { PageReference theRef = new PageReference('/apex/RFQConfirmation?id=' + rfqId); theRef.setRedirect(true); return theRef; }//end done method

 

}//end class

 

 

 

<apex:page standardController="Opportunity" extensions="RFQController" showHeader="false"> <!-- <apex:relatedList list="SDV_Tech_Specifications__r"/>--> <apex:pageBlock id="TechSpecList" title="Requested Specifications"> <apex:pageBlockButtons location="top" > <apex:commandButton value="New" action="{!addNew}" /> </apex:pageBlockButtons> <apex:pageBlockTable var="spec" value="{!Opportunity.SDV_Tech_Specifications__r}" columns="15"> <apex:column > <apex:outputLink value="/apex/sdvSpec?id={!spec.Id}&rfq={!Opportunity.Id}">Edit</apex:outputLink> </apex:column> <apex:column value="{!spec.Qty__c}" /> <apex:column value="{!spec.Rated_Max_kV__c}" /> <apex:column value="{!spec.Rated_Short_kA__c}" /> <apex:column value="{!spec.Rated_Cont_A__c}" /> <apex:column value="{!spec.Lightning_Impulse_BIL__c}" /> <apex:column value="{!spec.Motor_Volt__c}" /> <apex:column value="{!spec.Close_Volt__c}" /> <apex:column value="{!spec.Trip_Volt__c}" /> <apex:column value="{!spec.Heater_Volt__c}" /> <apex:column value="{!spec.Substation__c}" /> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Attached Specifications"> <apex:pageBlockButtons location="top" > <apex:commandButton value="Add Attachment" action="{!addNew}" /> </apex:pageBlockButtons> <apex:pageBlockTable columns="1" var="att" value="{!Opportunity.attachments}"> <apex:column value="{!att.Name}" /> </apex:pageBlockTable> </apex:pageBlock> <br/> <center><apex:commandButton style="font-size:16px" value="Finish" action="{!finish}" /></center> </apex:form> </apex:page>

 

 

 


 

 

I'd like to set up a field on a visualforce page where users can upload PDF's. I'm having trouble figuring out how to do this with a controller extension. I've got a custom object which is a child object of opportunity. I'm passing the Id of the opportunity to my page as a parameter 'rfq', and attempting to assign that id in the controller to the attachment before inserting it.

public class TechSpecController {

rfqId Id;

Attachment att;

public TechSpecController(ApexPages.StandardController theController){

this.spec = (SDV_Tech_Specification__c) theController.getRecord();
rfqId = ApexPages.currentPage().getParameters().get('rfq');
att = new Attachment();

}

 

public PageReference attach() {
att.ParentId = rfqId;
insert att;
return ApexPages.currentPage();
}

}

 

I'm having trouble tying the <apex:inputFile> to the attachment field. I'm getting the error:  Unknown property 'SDV_Tech_Specification__cStandardController.att'   

 

 

<apex:page standardController="SDV_Tech_Specification__c" extensions="TechSpecController" showHeader="false">

<apex:inputFile value="{!att.body}" filename="{!att.name}"/>
</apex:page>

 

Obviously it's looking for a variable in the standardController, so I guess my question is: Can you use an extension and refer to the fields within that extension in the way I'm trying to? If not, is there another way to do it?

 

 

 

Message Edited by dwwright on 03-04-2010 11:50 AM

I have a custom object which serves as a data entry form. The "output" of this object is a visualforce page that displays the fields niceley formatted and set to renderas="pdf". A requirement I have is for users to be able to attach pdfs to this object and print them along with the contents of the object itself. I need to be able to display the attached pdf's in the visualforce page. Currently I'm attempting to do it using the following code:

 

<apex:repeat var="att" value="{!Quality_Document__c.attachments}">
<apex:iframe src="/servlet/servlet.FileDownload-file={!att.Id}"/>
</apex:repeat>

 

 Where Quality_Document__c is my custom object. When I try this, the pdf page displays nothing. When I remove the renderas="pdf", it shows whitespace. If anybody has any ideas as to why this is, or has suggestions for alternate methods of doing this, please let me know!

 

Message Edited by dwwright on 03-04-2010 11:10 AM

I am attempting to make changes to text fields on the parent object in a master-detail relationship between two custom objects. I'm making these changes in a trigger, using the statement:

 

Child__c.Master__r.Master_Field__c = 'myText';

 

Upon executing the trigger, I'm getting the following error:

 

System.DmlException: Update failed. First exception on row 0 with id a03A00000010LifIAE; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, updateValidationStatus: execution of BeforeUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

 

This error message occured when attempting to save one of my child objects. The master and the child both already exist in the database, so I'm not sure why I'm getting null when referencing the parent, unless upward traversal through relationships is not allowed (Which I'm not aware of). Any pointers?

I'm trying to create a picklist using <apex:selectList>, populate it with my own selections, and require the field to contain a value. Here's my code:

 

 

<apex:selectList required="true" size="1" value="{!SDQA__c.Inspector_Stamp1__c}" > <apex:selectOption itemLabel="{!SDQA__c.Inspector_Stamp1__c}" itemValue="{!SDQA__c.Inspector_Stamp1__c}" /> <apex:selectOption itemLabel="{!$User.FirstName} {!$User.LastName}" itemValue="{!$User.FirstName} {!$User.LastName}" /> <apex:selectOption itemLabel="N/A" itemValue="N/A" /> </apex:selectList>

 

The first value defaults to whatever the field currently contains (which will initially be null). The other two options are either the users First Name+Last Name, or N/A. The problem is that even though I have required="true", there is no validation enforced on this field (The red "required" bar doesn't even show up beside it). Anybody have an idea as to why that is?

 

 

I have a Master-Detail relationship set up between two custom objects. The Master object is viewed and edited through a visualforce page. The child objects show up as a related list on that page. These child objects are also viewed and edited through a visual force page.

 

What I want to do is iterate through all instances of the child object that are currently attached to the master object, displaying their contents in a visualforce page which is embedded on the main page for the master object. Right now I'm attempting to do this with <apex:dataTable>

 

 

<apex:dataTable value="{!Quality_Document__c.SDQA__r}" var="S"> <apex:column> <apex:include pageName="SDQA180" /> </apex:column> </apex:dataTable>

 

 SDQA180 is the name of the display page for these child objects. I would like to embed an instance of this page for each child object that exists. How can I reference this page along with the Id of the current child object, so that the information for each child object is displayed in its own embedded page?

 

Many thanks

 

 

 

I'm building a visualforce page into a form which my users will fill out. The form will have to be regularly saved, and sometimes certain values will cause formula fields on my page to change. The problem is that my controller save method returns ApexPages.currentPage() and when this happens, changes to the formula fields are not reflected until you navigate away from the page and back to it. Is there a way to return a page from my save method such that these formula fields will be displayed with their updated values?
I'm having trouble displaying the related list for the child object in a master-detail relationship. On the standard WYSIWYG page layout, I can add the related list for the child object just fine. On a visualforce page (with the parent object as the standard controller) when I try to use:

<apex:page standardController="Quality_Document__c" >

<.... some code here ..... >

<apex:relatedList list="S180__c" />

 I get the error message:

 

'S180__c' is not a valid child relationship name for entity Quality Document

 

Help?

I've got a page full of input fields that I want to print. To do this, I'm mirroring the page, making modifications so it looks printable, and then using renderas="pdf." I want to have a button on the input page that links directly to the pdf version with the ID of the input record, so that all the fields are filled in on the PDF version for that input record. I've tried to do the following, which links to the pdf page, but doesnt display the information from the record.

 

 

<apex:commandButton style="font-size:14px" action="{!URLFOR($Page.DocPrintPage, MyObject__c.Id)}" value="Print" />

 

Any ideas?

 

 

I want to dynamically render sections of a page based on picklist values. To do that, I'm utilizing the "rendered=" attribute, and evaluating the values of a picklist to determine whether the section should display or not. My code is below

<apex:variable var="SEL" value="My_Object__c.Selection__c"/> <apex:pageBlock id="Section 123" rendered="{!SEL == '123'}"> <h1>This section represents Section 123</h1> </apex:pageBlock>

 In this case, I want Section 123 to display whenever the picklist value is "123". Can someone help with this?

I have a requirement to show a section only on button click. here is the code I have tried, but no luck. can someone tell me what is the error in the below code

 

VF code :

 

<apex:page controller="testRenderCtrl">
<apex:form>
    <apex:commandButton value="Submit" action="{!submit}" reRender="panelId"/>
    <apex:outputPanel  rendered = "{!flag}"  id = "panelId">
    <apex:pageblock >
        <apex:pageblockSection title = "Contact Information">
            <apex:inputField value="{!con.firstname}"/>
            <apex:inputField value="{!con.lastname}"/>                                              
        </apex:pageblockSection>
    </apex:pageblock>
    </apex:outputPanel>
    </apex:form>
</apex:page>

 

 

Controller code

 

public class testRenderCtrl {
    public Contact con {get;set;}    
    public boolean flag = false;    
    public boolean getFlag(){
        return flag;
    }
    public void setFlag(boolean flg){
        flag = flg;
    }    
    public void submit(){
     System.debug('****');
     flag = true;   
    }
}

 

Thanks,

YP

 

Hi,

I have a query retrieving the userinfo from user in a trigger.

 

Here i am retrieving a custom field from  user object.

Below is the query: 

 

String userid= userinfo.getUserId();


User[] userType = [select u.custom__c from User u where u.Id=:userid limit 1];

 

the exception is:

Apex script unhandled trigger exception by user/organization: 00540000001RUm8/00D300000001EBY caused by: System.Exception: Too many SOQL queries: 21

 

can anyone whats wrong eith the query to avoid gov limits.

Hi community,

 

Wondering if anyone can shed me some lights. I'm this close to bang my head against the wall.

 

On our Force.com Sites, we have a "Case Study" page which lists some PDF/Excel/Words files. These files are stored in Documents in Salesforce. We want people visit our site to download them.

 

I wrote a simple VF page to output a download link, and a controller to query the Document object. But when I click on the Download link, I get the "Authorization Required" error message. I guess this is to do with Security setting between the Documents Object and the Guest User License. I did grant the Read permission on this object but no luck.

 

Is there any way to make this work? I don't really want to use Static Resource to hold these PDF files.

 

Here is my code:

 

DocumentDownload.page

 

<apex:page controller="DocumentCon" action="{!getFile}">
<apex:outputLink value="/servlet/servlet.FileDownload?file={!doc.Id}&oid={!$Organization.Id}">
Download Now!
</apex:outputLink>
</apex:page>

 

 

DocumentCon.cls

 

public class DocumentCon {	
public Document doc {get;set;}

public PageReference getFile() {
String fileId = System.currentPageReference().getParameters().get('id');

if(fileId != null) {
doc = [SELECT Id, Name, Description, ContentType, Type, Url, BodyLength, Body
FROM Document WHERE Id = :fileId];
}
return null;
}
}

 

 

 

I'm trying to build an inventory catalog from some data stored in a custom object in Salesforce. One of the fields on the custom object stores the Id of a document that is an externally available image.

 

I'm trying to build this catalog in a Sites page and make this image appear. I'm currently doing this:

 

 

<apex:image url="/servlet/servlet.FileDownload?file={!Inventory__c.Image_URL__c}" />

 This works fine when I'm logged into Salesforce and viewing the Visualforce page directly.

 

Once I navigate to the sites page and try to view it, nothing comes up. I'm confirmed that the image is externally available, and I've set the Sites profile to "Read" for Document objects.

 

Does anyone know how you actually take advantage of externally available images and make them VISIBLE externally?

 

Hello Everyone,

 

I have created a relationship in between Case and my Custom Object ( CR_Reply). So CR_Reply have relational field rCase__r.

 

Now what I'm trying to do :

 

I have created a Visualforce page, on which I have added Custom Object ( CR_Reply ) fields. On this page I have passed CaseID as querystring Parameter.

 

I just want to display read-only details of Case i.e. Case # and Subject on top of this Custom Object page.

 

Please let me know if anybody have done similar work before.

 

Thanks

Sakshi

I am new to visualforce development and I have a question regarding lookup fields.

 

I have a visualforce page in which I am displaying data using jqgrid. The controller returns json data, which is consumed by the jqgrid. This works fine.

When I select and edit a row,  jqgrid generates a form dyanmically with HTML input field based on the column definition given  and prepopulates the data for that row  under each field.

Now my problem is , one of the field in the form is a look up field  and I want to show the lookupfield icon next to the field. in otherwords, I want to mimic the behaviour of lookup field on a html input field.

 

Does any one have suggestions on how this can be done?

 

Help much appreciated.

jackson

Hey everyone,

 

This trigger query is killing me.

 

I am writing a trigger to sum up custom field Scores in Contact.

 

I want to display the sum in Account.

 

I want to query the database for all the Scores for each Contact in an Account.

 

I guess my fundamental understanding of apex code sucks, nothing i'm doing seems to even compile.

Here's my code:

 

 

trigger sumContactScore on Account (after insert, after update) {
	
	Set<Id> accIDs = new Set<Id>();
	for(Account a: Trigger.new){
		accIDs.add(a.Id);
	}
	
	for(Account a : Trigger.new){
		
		Double sum = 0;

		List<Contact> scoreList = new List<Contact>();

		scoreList = [SELECT LS_Implicit_Contact_Score__c FROM Contact WHERE Email != null and Contact.AccountId in :accIDs];
		
		for(Contact i : scoreList){
			sum += i.LS_Implicit_Contact_Score__c;
		}
		
		a.Sum_of_Implicit_Behavior_Scores__c = sum;	
	}

}

 

 

 

Help.

  • July 22, 2010
  • Like
  • 0

I am utilizing Sites and my Visualforce pages use a custom object as the standard controller with an extension for additional functionality. 

 

How do I reference fields directly on a Visualforce page? For example, I have two fields that only have id's and no input value.

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VEReq" for="test_us001vereq" />
  <apex:inputTextarea id="test_us001vereq"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001_VERes" for="test_us001veres" />
  <apex:inputTextarea id="test_us001veres" />
</apex:pageBlockSectionItem>

 

I want to combine the input from these two Text Area Fields into one field which does have a value, meaning upon save the concatenated (combined) value will be entered (saved) into the database. 

 

Example:

<apex:pageBlockSectionItem >
  <apex:outputLabel value="US001" for="test_us001" />
  <apex:inputTextArea value="{!SK__c.US001__c}" id="test_us001" />
</apex:pageBlockSectionItem>

 

What options do I have to accomplish this task. I have spent 4 days looking at the forums, code examples, etc. and can not figure out how to make this work. Any suggestions, ideas, code examples, and/or links are much appreciated. Please let me know if this is unclear and I will provide more detail.

 

Also, for anyone familiar with MS Access Databases, this would be similar to bound/unbound fields and how to reference those fields within a form via VBA etc.

Hi,

 

I have visualforce page showing report data in a page block table. I want to show this page as dashboard component. Is there any way to achieve this easily? I have heard that dashboard component wont get created if you use a Standard Controller, but if you use Controller class or call/refer a page having StandardSetController Class from the concerned vf page, you may have the component available.

 

Could you please advise on this.

 

 

Thanks,

 

Vimal

hi ,

 

i have a  requirement with my client for creating 

 

1. I need to create Some Dashboard Reports in VF Sites

2. Will Dashboard menu appear in VF Sites

 

So i taught of working on building dashboards on Visualforce pages and then i didnt find any example for that,Is it possible to do that

 

can anybody help me in this issue,

We have an intermediary new lead page that takes basic fields (name, phone, email, company) and searchs showing possible duplicates. When one is not found then the user can choose to create his new lead. The lead is created with all the data the rep has already filled out, inserted and then shown to the user via a a pagereference. 

 

Is there a way to not "insert" the lead before showing it? I would like for agent's to have a chance to change some other field data before the initial insert trigger is fired. I just want to open the lead to its edit page 

I'm trying to give "apex managed sharing" a test run. I've created a custom object (in my sandbox) and I'm trying to run through how to handle creating share objects.

 

Right now, I'm getting a compile error that appears to be a syntactical error, but I can't figure it out.

 

In the documentation Here, the description of how to handle doing this is pretty clear: MyCustomObject__Share. In the example, referencing their Job__c object is done as "Job__Share".

 

My object is called RFQ. The api name is RFQ__c, so I would expect the share name to be RFQ__Share. I'm getting the error: "Invalid Type: RFQ__Share" when trying to compile my code. Here's a snippet:

 

 

/*
* Trigger to test Apex Managed Sharing
*/
trigger AssignSharing on RFQ__c (after insert) {
List<RFQ__Share> shares = new List<RFQ__Share>(); List<String> srNums = new List<String>(); Map<String, Id> userIds = new Map<String, Id>(); RFQ__Share shr = new RFQ__Share(); for(RFQ__c rfq : trigger.new) { //for each comma separated SR Num in the SR Num field, add it to //the list of relevant SR nums for(String num : rfq.Sales_Responsible_Numbers__c.split(',',0)) { srNums.add(num); } } //SR Nums now holds all the Sales Responsible numbers that apply to the //rfq's being inserted, so we can query them from the database; //next step is to iterate through all the users who will be assigned a
//sharing rule (query result)
//create a map of SR#s to Ids for quick reference later for(User u : [SELECT Id, Sales_Responsible_Number__c from User where Sales_Responsible_Number__c in :srNums]) { userIds.put(u.Sales_Responsible_Number__c, u.Id); } //userIds now maps each SR# to a user Id //for each new RFQ, assign the users that need to be given share priviledges
 for(RFQ__c rfq : trigger.new) { //for each sales responsible number for(String s :srNums) { //if this RFQ has that sales responsible number if(rfq.Sales_Responsible_Numbers__c.contains(s)) { //create a sharing rule that allows the corresponding user to be added shr.ParentId = rfq.Id; shr.AccessLevel = 'edit'; shr.UserOrGroupId = userIds.get(s); shr.RowCause = Schema.rfq__Share.RowCause.SalesResponsible__c; shr.add(shares); } }//end for loops over srNums for this rfq }//end for (trigger.new) insert shares; }//end trigger

 

(Don't make fun of my code... it's for testing, not even compiled once yet, and not made to be efficient, I just want to get it to compile)

 

 

Any insight?

Hi All-

      I'm sure this is simple but I can't find a simple answer.  I have a couple of different page layouts for leads that multiple users need to see.  Since a page layout is assigned per user, the only way around this was to create a visualforce page for the second page layout, time consuming but not a problem.   So now I need a way for the user to choose which page layout they see when creating a new lead.  I want to have them choose the LEADS tab, then from the LEADS HOME page launch new "custom" lead as well as the "standard" page layout that is assigned to them.

 

Is there a way to customize and add buttons to the TAB HOME page for a standard object like LEADS or do I have to create a VForce page to mimick this?  Thanks in advance for your help!!

I'm pretty new to this and I see other people have struggled with custom date pickers...

 

I have a custom VF task page.  I am trying to mimic the reminder section of the standard task screen.

 

I am usting an outputPanel so I can have a checkbox, input field (for date) and select field (for time).

 

The fields display fine and the datepicker lets me pick a date, but when I save, I am not able to get the selected date value back into my controller class.  The !ReminderDate comes back empty.

The !ReminderTime comes back fine.  

Neither field is bound to an SObject.

 

Is there another way?

 

Thanks,  Kevin.

 

 

             <apex:pageBlockSection title="Reminder" collapsible="false" rendered="true">                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel id="taskAddReminderLabel" for="taskAddReminder" value="Add Reminder" />                    
                    <apex:outputPanel id="taskAddReminderOutputPanel" >
                    <apex:inputCheckbox id="taskAddReminder" value="{!AddReminder}">
                        <!-- <apex:actionSupport event="onchange" rerender="taskInformation" action="{!Refresh}"/> -->
                    </apex:inputCheckbox>                                        
                    <span id="dateSpan" class="dateInput dateOnlyInput"><input id="taskReminderDate2" name="taskReminderDate2" value="{!ReminderDate}" onfocus="DatePicker.pickDate(true, 'taskReminderDate2', false);" size="12" type="text" /><span class="dateFormat"></span></span>                    
                    <apex:selectList id="taskAddReminderSelectList" value="{!ReminderTime}" multiselect="false" size="1">
                        <apex:selectOptions value="{!TaskReminderList}"/>
                    </apex:selectList>                 
                    </apex:outputPanel>                                    
                </apex:pageBlockSectionItem>            
            </apex:pageBlockSection>   

 

 

I'm trying to create a page that allows my users to fill in fields, attach as many files as they want, and then submit the information, creating a new lead with all the attachments.

 

What I want to do is let the user attach files BEFORE submitting, meaning BEFORE the Lead is actually inserted into the database. To try to accomplish this, I'm creating a list of attachments in the controller and then holding the attachments there. When the user clicks "submit" I then insert the Lead and assign all of the attachments in the list to that Lead.

 

The goal here is to be able to submit the Lead and its Attachments at the same time.

 

I'm hitting the viewstate size limit (I'm growing to dislike that error very much.) Is there a way to efficiently gather attachments before inserting them into the DB? Below are my relevant code snippets:

 

 

public class newLeadExtension {

public Lead theLead;
public String theName {get; set;}
public Attachment att {get; private set;} //Holds value from inputFile
public List<Attachment> attachments {get; set;} //Holds attachments
public List<String> attachmentNames {get; set;} //Holds atachment names

//Get the lead from the standardcontroller
public newLeadExtension(ApexPages.StandardController cont) {
theLead = (Lead)cont.getRecord();
att = new Attachment();
attachmentNames = new List<String>();
attachments = new List<Attachment>();
}

public PageReference attach() {
attachments.add(att);
attachmentNames.add(att.Name);
return null;
}
}

 

Attach A File:<br/>
<apex:inputFile value="{!att.Body}" filename="{!att.Name}" />
<apex:commandButton value="Attach" action="{!attach}"/>

Attached Files:<br/>
<apex:repeat var="att" value="{!attachmentNames}" >
&nbsp;&nbsp;{!att}<br/>
</apex:repeat>

 

 

(The "submit" method isn't shown here, but it just inserts the lead, then iterates through the attachment list assigning each parent ID as the lead and inserting it)

 

Thanks for any help you can provide!

I want to send an email thanking the Primary Contact on an Opportunity when we mark the corresponding Opportunity Closed Won. But I don't see that object (Opportunity Contact Role) as an option when setting up the email alert.

Any suggestions?

Jane

  • October 24, 2008
  • Like
  • 0