You need to sign in to do that
Don't have an account?
Pre-populate lookup fields when create new record from related list
Hey salesforce experts
I have issue and whole day I can't resolve it..
I have custom object parent 'FundEZ_Codes__c' and child 'GL_Route' lookup connection. So I have to override the new button from related list 'Gl_Routes' in FundEz_Codes__c to inherit this lookup field. I'm trying with URL Hack but something I miss.. Here is my code:
<apex:page standardController="GL_Route__c" action="{!URLFOR($Action.GL_Route__c.New, null, ['retURL'='/a0r/o','Name'='AUTO-POPULATED', 'CF00N6C000000Ks4C_lkid'=GL_Route__c.GL_Map_Code_1__c, 'CF00N6C000000Ks4C'=GL_Route__c.GL_Map_Code_1__r.Name], true)}">
</apex:page>
The problem is that GL_Route__c.GL_Map_Code_1__r.Name is empty and didn't pre-populate the field .. But this works in formula fields of GL_Route..
Can you help me PLSS
Please try with extension and add reference of fields inside contructor.
Here is hint how to follow:
Please let me know if it works.
All the best!!
Thanks
Gulshan Raj
Is this works?
Please let me know if you have any question.
Thanks
Gulshan Raj
Hi Gulshan Raj
Thanks for response but for regred it doesn't work.. Next error when I try to cread new record from related list:
GL_Route__c.GL_Map_Code_1__r.Name does not belong to SObject type GL_Route__c
Thanks for fast response!
Did you added extension to your page. I tried in my org and it works.
Here what I did:
I have three object Account, Dancer and Delivery have relationship like this:
Delivery is parent of both Account and Dancer
Account is parent of Dancer.
So, when I create Dancer object it need reference of both account and delivery. Account also store reference of Delivery. So, I am populating value of Delivery from account reference.
Here is my code:
VF Page:
Extension class:
I have cutom button on detail page of account from where I am calling this VF page.
After clicking on this button it gives me pre-poulate values.
Please take this reference and do necessary changes.
If this helps you, mark this question as solved and choose best answer so it will help other in future to judge correct solution.
Thanks
Gulshan Raj
Thanks for acknowlege.
Regards
Gulshan Raj
I too have the same issue but tried to create a new button on the related list but doesn't meet my requirement as I have many recordtypes, and coding didn't solve my issue too. I was researching, learned that Soql query will help in acheiving it via controller/Extension?
Issue: please need some help to solve the issue - in populating parent Object name (lookup) while creating a child record with new button.
Note: I have overridden new button with controller to redirect with VF page on seleted recordtype, It works good on new button fron the object but is not populating the parent lookup while creating a record from related list.
I really appreciate you help!
Thanks in advance.