0

I want to create a custom button on parent record to add records in child object. I created the custom button with url for new child record on parent object but the parent name does not auto populate in the new child record edit mode and I have to enter it manually and then save the record. Is their a way to get this working.

Here is my code,

!URLFOR($Action.Rep_Expense__c.New,null,["00No0000000lFwWEAU"=Contact.Id],true)

2 Answers 2

2

I would recommend taking a look at a quick action vs using a custom button url hack since they do not work in Lightning experience and are not supported by salesforce and therefor could break without notice but if you want to continue with the URL hack then you need to change your paramaters to set both the id and the name and also include CF before the field ID for custom fields: {!URLFOR($Action.Rep_Expense__c.New,null,[CF00No0000000lFwWEAU=Contact.Id, CF00No0000000lFwWEAU_lkid=Contact.Name],true)}

9
  • I used the code and got the below error. SObject row was retrieved via SOQL without querying the requested field: Contact.Name
    – Dinesh
    Commented Nov 5, 2015 at 17:01
  • @Dinesh is this button be placed on a visualforce page and if yes does that visualforce page have access to the contact name?
    – Jenny B
    Commented Nov 5, 2015 at 17:16
  • Yes Jenny, the button is on visualforce page and it do have access to contact name field. <apex:page standardController="Contact">
    – Dinesh
    Commented Nov 5, 2015 at 18:07
  • @Dinesh but do you specifically have the Name field rendered on the page?
    – Jenny B
    Commented Nov 5, 2015 at 18:08
  • Yes, I have rendered Name field in page. I created custom button with this code "/a08/e?CF00No0000000lFwW={!Contact.Name}&CF00No0000000lFwW_lkid={!Contact.Id}" and now its working fine. Thanks Jenny for helping me to fix the issue.
    – Dinesh
    Commented Nov 5, 2015 at 18:17
1

You can do this with URL Hacking.

As a quick recap – URL hacking is the process of pre-populating data in a new record with data from a record you are currently working off using a custom button to launch this new record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .