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
Matt Morris 24Matt Morris 24 

Enhanced data grid - how to pass field value from parent record into createRecord action?

I have been configuring the SalesforceLabs Enhanced Data Grid app and its gone well so far. However I am struggling to work out how to pass a value from the parent record into the payload of e.force:createRecord action.

My payload is as follows:
{"entityApiName":"Action__c",
"recordTypeId" : "0124J0000009Y2pQAE",
"defaultFieldValues" : {"Session__c":"#parentrecordId#", "Start_date_time__c" : "#Session__c.In_Form__Start_date_time__c#", "End_date_time__c" : "#Session__c.In_Form__End_date_time__c#"}}
I get the right entity, the right Record Type and the right Session value. However the date/time fields don't get populated.

The user guide has the example of creating a Contact record from the Account parent and it reads...
"#AnyAPIName# - replaced with corresponding value from row (as long as it’s in the fields displayed). Eg #Account.LastModifiedBy.Name#"
Which is a bit confusing because how can the field from the parent object be displayed in the row (which by definition is the child)!

Can anyone help?
Gina Szafraniec 3Gina Szafraniec 3
Hi Matt, 
Does this help? Session__c should be Session__r.

"Start_date_time__c" : "#Session__r.In_Form__Start_date_time__c#", "End_date_time__c" : "#Session__r.In_Form__End_date_time__c#"
Matt Morris 24Matt Morris 24
Thanks for your response Gina and pointing out that I had made a mistake in the syntax referencing the custom object. However after updating the payload these values are still not passed into the create record page.
Gina Szafraniec 3Gina Szafraniec 3
Hi Matt,

The two fields that you are having trouble getting must not be in your Enhanced Sortable Data Grid list view and they need to be there. You asked a question about the following because it was confusing: #AnyAPIName# - replaced with corresponding value from row (as long as it’s in the fields displayed). You were confused about the Parent field and value showing up in a Child list. This tool can do that. The two fields you need would be Session__r.In_Form__Start_date_time__c and Session__r.In_Form__End_date_time__c. The field finder tool can help with getting the correct API name without having to go to Setup. I look at this feature like a formula field without having to create a formula field. 

I think the problem is that you want the values from those Parent fields when you create a record but you don't want the fields to show in the list. That would be an awesome feature but I don't think the tool can do it. 
Matt Morris 24Matt Morris 24
Thanks for following up on this Gina. I guess I had hoped the tool was more powerful than it is. However I have managed to resolve the issue using a before save Flow (so glad that this feature was released recently)
Raju KorotanaRaju Korotana
I have the same error but adding the parent record field to list view isnt working?

00201 FX5__Job__r.Treatment_Wellbore__c <<- this is in my list view and my code for new record is

{
"entityApiName":"FX5__Ticket__c",
"navigationLocation": "LOOKUP",
"defaultFieldValues": {"FX5__Job__c" : "#parentrecordid#",
 "RecordTypeId" : "012f4000000JmLYAA0",
"Treatment_Design__c" : "#FX5__Job__r.Treatment_Wellbore__c#"}
}

when i use the button i get error

Looks like there's a problem.
Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details.
Error ID: 503534760-55543 (-1065292068)

screenshot