You need to sign in to do that
Don't have an account?

Pass Parameter in $Action New
Hi All,
Can anyone share an idea on how to pass a parameter in the $Action New. I am using commandbutton in a custom vf page in a related list that is when click it will be redirected to the creation of new record with its parent object being autopopulated in the lookup. Here's my code:
<apex:commandButton action="{!URLFOR($Action.Tutor_Session__c.New)}" value="New Tutor Session" id="theButton" />
I need to pass something in the action of commandbutton so that it will autopopulate the lookup in the new page when redirected.
Please advise.
Thanks in advance
Hi Bhawani,
I just got it right. Thank you so much. :)
One more thing, why is it that when I got redirected to that page to create new tutor session, when I press the cancel, it redirects to its own page, instead it should redirect to its parent page since that is only a related list.
Once again, thank you
All Answers
Hi Bwahani,
I tried your suggestion something like this but its not working please correct if I'm missing something
<apex:commandButton action="{!URLFOR($Action.Tutor_Session__c.New,null,['Tutor_Id__c'='a04T0000006BGNt'])}" value="New Tutor Session" id="theButton"/>
Thanks in advance
Hi All,
I getting almost of it. I have just only a problem in the code
<apex:commandButton action="{!URLFOR($Action.Tutor_Session__c.New,null,['CF00NA0000006EWy0'= '{!currName.Name}'])}" value="New Tutor Session" id="theButton"/>
What is happening is that salesforce treat that red mark part as a string when loaded in Salesforce it returns the exact '{!currName.Name}' string not the actual value . If I remove the single quote it raises a syntax error. Please advise.
Please try this. You can replace "obj.id" with your values.
Thanks
Devendra
Hi Devenda,
I tried my code as per your advise something like this
<apex:commandButton action="{!URLFOR($Action.Tutor_Session__c.New,null,[retURL=$Page.Tutor_Session__c+'?id='+'{!currName.Id}'], true)}" value="New Tutor Session" id="theButton"/>
Nothing happens. My goal is to autopopulate a lookupfield when the new tutor session button is click since it was click in the related list. The parent object should be populated in the lookup.
Instead of this
Please try this one.
Thanks
Devendra
Hi Devendra,
Sorry I was not clear enough. Another issue is that Tutor_Session__c says it does not exist because this is not a vf custom page, It is a standard tab for a custom object. Is there another way to address that?
Each lookup field rendeded on UI with a hidden field to grab the ID of looked up record.
I mean, If I select an Account on Contact page then there will be two field to hold this information
Field1 to hold the Account Name
Field2 to hold the Account Id
You need to grab the id of your lookupfield and hidden id field from view source and then pass the value in the URL for that.
like
<apex:commandButton action="{!URLFOR($Action.Contact.New,null
,['lookupNameId'= '{!currName.Name}','lookupRecordId'= '{!currName.Id}'])}" value="New Tutor Session" id="theButton"/>
Use this
Hi Bhawani,
I'm almost there, Yes I can see that in the source but the problem right now is Salesforce does not load the {!currName.Name} , and its proper value, instead it loads the whole string of '{!currName.Name}'
<apex:commandButton action="{!URLFOR($Action.Tutor_Session__c.New,null
,['CF00NA0000006EWy0'= '{!currName.Name}'])}" value="New Tutor Session" id="theButton"/>
I tried removing the single quote but it says syntax error
Use only currName.Name instead of '{!currName.Name}'.
Remove singlequote('), bracket({}) and ! mark
If we are using $Page then we will have to give the valid visualforce page name with it. Can you please tell me what exactly do you want to pass as parameters?
Thanks
Devendra
Hi Bhawani,
I just got it right. Thank you so much. :)
One more thing, why is it that when I got redirected to that page to create new tutor session, when I press the cancel, it redirects to its own page, instead it should redirect to its parent page since that is only a related list.
Once again, thank you
Hi Devendra,
I was planning to the pass the name or id parameter in which it autopopulates a lookup field when you click a new button in the related list.
Regards
You only need to create a command with action="{!cancel}" . Don't need to do ant coding for this. It will redirect you from where you came.
I'm a newbie force.com developer: I'm triyng to implement a VF page using URL function passing parameter based on the selected record from a list in the previous VF page, but I have a problem with the autopopulating of a lookup field: can anyone help me, please?
This is the code for my VF page:
<apex:page controller="Sebi_ControllerSelezionaMacchina">
<apex:outputLabel value="{!exec_message}" id="msg"/>
<apex:pageBlock >
<apex:PageBlockTable value="{!ListaCar}" var="c" columns="3">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.AvailabilityLights__c}"/>
<apex:column value="{!c.RatingCar__c}"/>
<apex:column >
<apex:form >
<apex:commandButton value="Select" action="{!URLFOR($Action.Journey__c.New,null
,['Car_Select' = '{!$c.Id}' ])}" />
<!-- 'lookupRecordId'= '{!currName.Id}' ['lookupFieldId'=value] ['Car_Select__c' = '{!c.Id}' ] -->
</apex:form>
</apex:column>
</apex:PageBlockTable>
</apex:pageBlock>
</apex:page>