Redirect to Create New Record passing the Master record name into child. Just like functionality from default New Record Salesforce button.

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I am trying to do a redirect to create a child record in a Master Detail Relationship and have the name of the Master record already listed in the lookup field.

In my case it is a Client with a Prescription. I want the "Client" field, which is the master, to be populated with the client's name "John Doe" as part of the redirect. If I go to the default Salesforce view and click the button I get the below URL (my site removed). How do I call the client's name John+Doe?? Everything I have tried actually gets passed into the field instead of calling the name. Any help would be greatly appreciated.

/a05/e?CF00NG000000CLpAE=John+Doe&CF00NG000000CLpAE_lkid=001G000001E6RZM&retURL=%2F001G000001E6RZMIA3%3Fnooverride%3D1
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hi Rich,

The main thing that you need to do is to modify your Skuid Page that's creating the new child record to "expect" to be handed the Client Id and Client Name as URL Parameters, and to use these two URL Parameters' values as defaults for the new Client record by creating Conditions on your new Client model.

So, for my example, i have a page called "NewContact" that let's you create a new Contact record, but the AccountId and Account Name can be passed in via URL Parameters. This makes it so that if you have a "New Contact" button on your Account detail page, you can prepopulate the new contact record with the Id of the Account.

Here's what the "NewContact" page looks like. Notice that there are 2 Conditions in the Model, one on the AccountId field --- NOTE: NOT on the Account.Id field, very different --- and one on the Account.Name field. THese are both "URL Parameter" Conditions. So our page is expecting to be passed 2 URL Parameters, one called "accountid", which will contain the Account's Id, e.g. 00100000000AAA, and one called "accountname", which will contain the Account's Name, e.g. "Genepoint".



which would for example result in the following if valid accountid and accountname URL Parameters are passed in to it:



So for your scenario, what I would do is to replace "accountid" with "CF00NG000000CLpAE_lkid", and "accountname" with "CF00NG000000CLpAE". That way this Skuid page will be able to take prepopulated values from standard Salesforce Page Layouts and use them. If your Client detail page has been overriden with a Skuid detail page, then your "New Prescription" button would not have to pass in these weird "CF...." parameters, it could just be something like:

/a05/e?clientname=John+Doe&clientid=001G000001E6RZM

instead of

/a05/e?CF00NG000000CLpAE=John+Doe&CF00NG000000CLpAE_lkid=001G000001E6RZM

BUT, if you have NOT overriden the Client detail page with Skuid, and you are JUST using Skuid for the "New Prescription" page, then you will have to use "CF00NG000000CLpAE_lkid" and "CF00NG000000CLpAE" as the URL Parameter names that your "New Prescription" Skuid Page is expecting.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
I am still struggling with this feature and with "After Save Redirect URL" and "After Cancel Redirect URL" I have tried three iterations /{{ID}}, {!Parameter.id}, and one other option found in the new record template. Would it be possible to have someone remote into my screen with me next week sometime and try to help me understand what I am doing wrong? I have everything else humming thanks to the community's help, I just need to get these 2 loose ends tied up.

Thank you!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Rich we can absoltely help you get this squared away. I'll contact you directly. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Rich - sorry we didn't get back to you sooner on the "after save redirect".   Here are a few pointers about redirects.

1. Your eventual URL will need to look somthing like this  https://na3.salesforce.com/0035000001rkkJS   Let's break that apart. 

The first part https://na3.salesforce.com    can be left out of all redirect url properties.  In almost all cases they will be correctly autopopulated. 
The backslash ( / ) is next,  and is almost always needed. 
The record ID is after that.  Because we want to go to a different record every time we need to use model merge syntax to pass this value dynamically. 

2. The best way to populate the syntax for the record Id is to use the field picker icon (to the right of the redirect property).  This shows the fields that are availabe in the model.  If you are in a page title, and are not using model data to do anything else,  you may want to select a different model to ensure model data will always be there,  or the record ID is the correct one. 

3. If there is not reliable model data, and you want to return to a record that was passed in a URL parameter - the syntax is as follows: {{$Param.<FieldName>}}  In the case Zach showed above it would be {{$Param.accountid}}

4. Sometimes the record ID is not available in the model connected to your save/cancel button but is available in other model data.  In that case you can use the syntax {{$Model.<ModelName>.data.0.<FieldName>}}     This will return the value for the field found in row 0 of the model. 

I think that in your case,  your redirect syntax will be /{{$Param.accountid}}

Let us know if that did not work. 
Photo of Jack Sanford

Jack Sanford, Champion

  • 8,322 Points 5k badge 2x thumb
I have a similar case but would like to pass A LOT of data into a new record... we want to create a Credit Memo that pulls info from several models: the main opportunity, borrowers, properties, collateral, covenants, borrowers' other opportunities, and possibly more. Are there other ways to create a new record that pulls in default data from other models?

Essentially what I want to do is display several field editors for each of the models in question, but then hit a Save button and save all the visible data to the related fields in a new Credit Memo object. 

(just to not wast my keystrokes...) I think I figured this out - if Credit Memo is almost entirely comprised of formula fields, then I can make a pop up with a Page Title related to the Credit Memo object and then all my field editors from other models underneath, with the save button saving any changes to the other models' fields PLUS creating a new Credit Memo.