+ Start a Discussion

Is it possible to pass record type Id in Lightning Data Services

Hi All  
I have a requirment like (navigating from custom quick action button  ) when creating new record from parent record I want to prepopulate all the manditory fields on child object based on the record type selection  . When I'm using  e. forcecreaterecord  event working fine but it returning complete layouts (all fields ) . 
Is it possible to pass record type Id in Lightning Data Services  , please suggest which is the best way to achieve this requirment ? 
Maharajan CMaharajan C
Hi Ram,

I will suggests the below apporaches: So you can choose the below any ones :

Approach 1: 

Quick Action alone not including the lightning component: But here you have to include the needed  fields in the Quck Action layout and here you can't add the Sections.

After creted the quickaction you can fill Predefined Field Values.

User-added image


Approach : 2

You can store the Record type id in the Custom Label  the in JS Client Controller you can set the record type id to e.force:createrecord event. but here you can only set the only one record type:

Access the Record type id from Custom Label:

in the button method add the below things

var recordTypeId = $A.get("$Label.c.labelName");

then in the event you can set the value:

var createRecordEvent = $A.get("e.force:createRecord");     
  "entityApiName": entityApiName,                    
   "recordTypeId": recordTypeId,

Approach 3: 

Add the record type selector in custom lightning component:


Can you please Let me know if it helps or not!!!

If it helps don't forget to mark this as a best answer!!!

Thanks Raj for your time and Approches ,
Approch 1 :
when go with standard prepopulation , prepopulated fields are read only mode and record type selection not possible 

Approch 2  & Approch 3:
when using standard event  e.force:createRecord , this will work but as per requirment  only manditory fields need to  prepopulate and those fields only visible to user  , when using standard event it will return all the fields .