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

populate a field from a lookup on a VF page
Hi All,
I'm trying to populate automatically a lookup field on a custom object, via a VF Page. So I have a small VF page, with a lookup, and a Save button with an hacked url behind the button. When I save, i'm correctly redirected to a new record on my custom object, but the lookup is populated with the ID of the previous lookup, and not the name. It is working, but it is not very user friendly !
Someone could help me on this topic ?
Thanks a lot
Here is my VF page
<apex:page standardController="Credit_Application__c">
<apex:form >
<apex:pageBlock title="New Credit Application" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="https://test.salesforce.com/a0d/e?who_id=&retURL=/&cancelURL=/&ent=Ev&CF00Nc0000000YaoU={!Credit_Application__c.Lessee_Name__c}&CF00Nc0000000YaoU_lkid={!Credit_Application__c.Lessee_Name__c}&00Nc0000000YKnQ=Draft&CurrencyIsoCode=CNY" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Leesee Information" columns="2">
<apex:inputField value="{!Credit_Application__c.Lessee_Name__c}"/>
<apex:CommandButton action="https://test.salesforce.com/001/e?retURL=%2F001%2Fo&RecordType=012c0000000CrzV&ent=Account" value="Create a new Leesee Account"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I'm trying to populate automatically a lookup field on a custom object, via a VF Page. So I have a small VF page, with a lookup, and a Save button with an hacked url behind the button. When I save, i'm correctly redirected to a new record on my custom object, but the lookup is populated with the ID of the previous lookup, and not the name. It is working, but it is not very user friendly !
Someone could help me on this topic ?
Thanks a lot
Here is my VF page
<apex:page standardController="Credit_Application__c">
<apex:form >
<apex:pageBlock title="New Credit Application" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="https://test.salesforce.com/a0d/e?who_id=&retURL=/&cancelURL=/&ent=Ev&CF00Nc0000000YaoU={!Credit_Application__c.Lessee_Name__c}&CF00Nc0000000YaoU_lkid={!Credit_Application__c.Lessee_Name__c}&00Nc0000000YKnQ=Draft&CurrencyIsoCode=CNY" value="Save"/>
<apex:commandButton action="{!cancel}" value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Leesee Information" columns="2">
<apex:inputField value="{!Credit_Application__c.Lessee_Name__c}"/>
<apex:CommandButton action="https://test.salesforce.com/001/e?retURL=%2F001%2Fo&RecordType=012c0000000CrzV&ent=Account" value="Create a new Leesee Account"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Shame on me !
All Answers
Credit_Application__c is a custom object
Lessee_Name__c is a lookup of Account object
check below link it may help you
http://raydehler.com/cloud/clod/salesforce-url-hacking-to-prepopulate-fields-on-a-standard-page-layout.html
On my VF Page, I have only a lookup field, which is a lookup on the Std Object Account :
<apex:inputField value="{!Credit_Application__c.Lessee_Name__c}"/>
The line below is used behind the Save button on my VF page, in order to create a new record in my custom Object Credit Application. Some fields are automatically populated, and also my lookup (ID = CF00Nc0000000YaoU)
<apex:commandButton action="https://test.salesforce.com/a0d/e?who_id=&retURL=/&cancelURL=/&ent=Ev&CF00Nc0000000YaoU={!Credit_Application__c.Lessee_Name__c}&CF00Nc0000000YaoU_lkid={!Credit_Application__c.Lessee_Name__c}&00Nc0000000YKnQ=Draft&CurrencyIsoCode=CNY" value="Save"/>
But the only way to retrieve the value inserted at the first step, is to map my lookup field (CF00Nc0000000YaoU) with the field of my VF Page ({!Credit_Application__c.Lessee_Name__c})
When I click on Save, i'm redirected to the Edit mode of my custom object record, but the lookup is fulfilled with the record ID of the account, not with the "visual" name. When I save it, the name is correctly displayed
I know that the field CF00Nc0000000YaoU should be filled with the Account Name, and the field CF00Nc0000000YaoU_lkid with the Account ID, but I don't know how to retrieve correctly the account name from my VF page (currently, only the ID is retrieved and inserted to the record)
Shame on me !