+ Start a Discussion
kostya_dekostya_de 

parameters for URLFOR function (Action.New)

I need to create VF page with button which creates new element related to current and add it to list. I want to fill automatically master field and maybe some additional fields.

 

Can I extend code below some how to make it?:

 

 <apex:commandButton action="{!URLFOR($Action.CF_OtherOp__c.New)}" value="new bussines opportunity"/>

 

If not how its possible to implement? 

  

Thanks,

  Kostja 

Best Answer chosen by Admin (Salesforce Developers) 
michaelforcemichaelforce

You sure can... use something like this:

 

 

{!URLFOR( $Action.CF_OtherOp__c.New,null,[EXAMPLE15CHARID=Record.Name, EXAMPLE15CHARID_lkid=Record.Id, PARAMETER2=SOMEVALUE, PARAMETER3=SOMEVALUE])}

 

 The "null" is because on a create there is no ID yet.  Replace "EXAMPLE15CHARID" (both of them) with the ID of the custom lookup field you have created and this will autopopulate the lookup when you get to the creation screen.  Lastly, the additional parameters are just to show you that you can pass as many values as you want to fields.

 

All Answers

michaelforcemichaelforce

You sure can... use something like this:

 

 

{!URLFOR( $Action.CF_OtherOp__c.New,null,[EXAMPLE15CHARID=Record.Name, EXAMPLE15CHARID_lkid=Record.Id, PARAMETER2=SOMEVALUE, PARAMETER3=SOMEVALUE])}

 

 The "null" is because on a create there is no ID yet.  Replace "EXAMPLE15CHARID" (both of them) with the ID of the custom lookup field you have created and this will autopopulate the lookup when you get to the creation screen.  Lastly, the additional parameters are just to show you that you can pass as many values as you want to fields.

 

This was selected as the best answer
kostya_dekostya_de

thank you, but how I can obtain Field ID. I copied/pasted field Id from url of field view page:

 

{!URLFOR($Action.CF_OtherOp__c.New, null, [00NT00000012yJJ=Record.Name, 00NT00000012yJJ_lkid=Record.Id])} 

 

But got the error: 

 

 

Error: Syntax error. Found '['

 

Is it possible to get ID of necessary field in general and how to apply it to this case? 

 

 

 

  
 
 
mtbclimbermtbclimber

It looks like you are trying to link into the standard page passing in values as request parameters. This is not a supported API and is subject to change/break at anytime.

 

If you want to pass values in a request as parameters it has to be to your own (vf) page using param names you define, i.e. your own API.

xxyyzzxxyyzz

I only just came across this post. You need to put the letters CF in front of the field id's.

 

 

{!URLFOR($Action.CF_OtherOp__c.New, null, [CF00NT00000012yJJ=Record.Name, CF00NT00000012yJJ_lkid=Record.Id])}