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
Lena RLena R 

Set Parent Id as parameter in e.force:createRecord event

Hi folks,

Does any one know if it's possible to set parent id parameter in e.force:createRecord event in Lightning Component or any workaround for this?

I have two custom objects in a master (Project)-detail (Task) relationship. I want to override the OOTB New button on the Tasks related list. When I click a custom Quick Action button from the Project page to create a new Task, I do some validation first and then if success I'd like to forward the user to the create new Task page with the parent field for Project to be populated like it works with the out of the box New button on the related list. Because the parent id is not being passed, when the new Task form gets loaded, the parent field appears open in the search mode and the user has to select the parent record which is very inconvenient. 

Would anyone have a suggestion? Thankyou in advance
Yogesh SheteYogesh Shete
Hi Lena,

You can use Object-specific quick action to create detail object record from master object record page. In Object-specific (create) quick action parent Id gets set automatically. You can add basic validation rules on quick action layout fields. Also you can predefined some of these values too.

Please refer,

Best Regards,
Yogesh Shete
Manish Sharma 105Manish Sharma 105
Please try this code...
var createRecordEvent = $A.get("e.force:createRecord");
            "entityApiName": "Opportunity",
                "Parent_id" : cmp.get("v.Parent_id"),
                "Name" : "Test anem",
                "AccountId" : cmp.get("v.accountId"),
            "recordTypeId": cmp.get("v.recordTypeId")
@Manish Sharma 105   - THANK YOU!