function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

VF page with New button using URLFOR - Can I default a value to pass on to the new record?

I have a VF page that was written by a former coworker.  It uses the URLFOR action for a "New" button.


<apex:pageBlock >
                <apex:pageBlockButtons >
                    <apex:commandButton value="New" action="{!URLFOR($Action.Case.NewCase)}" />

This is to create a new case in our Partner Portal, but I'd like to default the Contact on the Case to be the Partner User creating the case (like standard behavior on the Customer Portal).  Is there a way to do that here?  I'm trying to get by since our developer left, so any assistance is appreciated.



You can pass parameters using URLFOR.  I don't know if the partner portal populates fields based on parameters in the URL, so it might not work.


You'll need to identify the id of the element in question on the page.  Assuming its 'cont1' you would need something like the following:


action="{!URLFOR($Action.Case.NewCase, null, [cont1='{!}'])"

 Note that this also assumes that you have the contact information available as a controller property named 'cont'.


Marc C.Marc C.
Bob, is there an equivalent syntax for custom button formulas? It seems that URLFOR($Action.MyObj__c.MyAction or even URLFOR($ doesn't work: "Error: Enter a URL that is valid and well-formed"