I had created a custom visualforce button as shown below. That would pre populate the look up field.

   <apex:commandLink  value="Create New Order" onclick="/a15/e?CF00N50000003qoqXEAU_lkid='{!Account.Id}'&CF00N50000003qoqXEAU='{!‌​Account.Name}'"/> -->
  <form action="{!URLFOR('/a15/e?' + 'retURL=%2Fa15%2Fo&CF00N50000003qoqX={!Account.Name}&CF00N50000003qoqX_lkid={!Account.Id}')}" target="_blank" >
       <input type="submit" value="Create New Order"/> 

After clicking the button the output displays as follows enter image description here

I want the URL to display as


  • 1
    You have to do something like this: 'retURL=%2Fa15%2Fo&CF00N50000003qoqX='+{!Account.Name}+'&CF00N50000003qoqX_lkid='+{!Account.Id}+'')}' – raym0nd Apr 4 '16 at 15:29
  • 1
    Also, its much better to redirect from the backend not the front end. Cause I have feeling that the Account.ID or name is not gonna be set when the page is loaded. So its better to use an action function and call a submit function in the back end. – raym0nd Apr 4 '16 at 15:32

Straight after {! you are in a server-side evaluated expression so there is no need to use further {! expression delimiters. Instead just concatenate the values.

So instead of:

{!URLFOR('/a15/e?' + 'retURL=%2Fa15%2Fo&CF00N50000003qoqX={!Account.Name}&CF00N50000003qoqX_lkid={!Account.Id}')}


{!URLFOR('/a15/e?' + 'retURL=%2Fa15%2Fo&CF00N50000003qoqX=' + Account.Name + '&CF00N50000003qoqX_lkid=' + Account.Id)}
  • Even after doing that it is showing the page and not prepopulating the look up fields ... the output is as " /a15/e?" – DominicSeb Apr 4 '16 at 15:50
  • @DominicSeb When using URLFOR I've passed parameters using his syntax {! URLFOR($Page.Form, null, [p1='abc', p2='xyz']) }; the issue might be escaping related. – Keith C Apr 4 '16 at 15:59
  • I tried using this as follows {!URLFOR($Action.Product_and_Services__c.New,null,['CF00N50000003qoqXEAU_lkid'='Account.Id' , 'CF00N50000003qoqXEAU'='Account.Name'] )}" target="_blank" It is still blank The look up fields are not getting pre populated – DominicSeb Apr 4 '16 at 16:15
  • @DominicSeb I would expect [CF00N50000003qoqXEAU_lkid = A‌​ccount.Id, CF00N50000003qoqXEAU = Account.Name] to work. – Keith C Apr 4 '16 at 16:23
  • I did the following <form action="{!URLFOR($Action.Product_and_Services__c.New,null,[CF00N50000003qoqXEAU_lkid=A‌​ccount.Id ,CF00N50000003qoqXEAU=Account.Name] )}" target="_blank" > I got the error " Syntax error" – DominicSeb Apr 4 '16 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.