function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JTull79JTull79 

New Custom Button that will populate the name with the name of the Parent Record

I have created a button call New Metric that I want to use to create a new record and to pre-populate the Name field. The object where the record is created is called RFP Metrics. RFP Metric is a Master-Detail relationship with an object called RFP Tracking. I am creating the record from the RFP Tracking record where RFP Metrics is a related list. The button uses OnClick Java script. Here is the code:

location.href = "a6t/e?Name={!RFP_Metrics__c.Related_RFP_Tracking__c}&CF00N70000003UZ6F={!RFP_Metrics__c.Related_RFP_Tracking__c}&CF00N70000003UZ6F_lkid={!RFP_Metrics__c.Related_RFP_TrackingId__c}&retURL={!RFP_Metrics__c.Link}"

It looks like the Name should populate the the Name of the related record. And because this is a Master-Detail relationship, it should populate the Related Record Id. When I click the button, a new record is created but nothing is populated. When I look at the URL after I clicked the button, it appears like this:

https://na5.salesforce.com/a6t/e?Name=&CF00N70000003UZ6F=&CF00N70000003UZ6F_lkid=&retURL=

It removes all of the merge field information. I have looked all across the internet and I can't figure out why this isn't working.
James LoghryJames Loghry
This seems like a great candidate to be replaced by a Publisher action.  The one and only Salesforce Wizard has an excellent post on this topic: http://thewizardnews.com/2014/01/08/great-url-hack-meet-the-chatter-publisher-action/
Salesforce WizardSalesforce Wizard
There's a lot of good reasons to move to a publisher action. The big one is that URL hacks like this are not officially supportive by Salesforce and you can see the start of their demise with the Lightning Experience UI. URL Hacks don't work in the Lightning Experience.

The only downsides of using a publisher action is 1. You need to be using Chatter and 2. It creates the record vs taking them to an edit page and pre-filling the fields. That means any fields you want to user to modify needs to be on the publisher action layout.

Your only other option is to use visualforce but that's typically overkill for most use cases.
JTull79JTull79
Thanks Guys, and yes I found out they weren't supported when I took this issue to Salesforce support.  I did just create the Chatter Action and it does work but it is a little clumsy with it just creating the record but not taking you there to edit it.  I know it is just a couple of click, but you know how users can be.  We also don't use Chatter hardly at all.  So even though it isn't supported in the future, it would be great if someone could help with this custom button.