You need to sign in to do that
Don't have an account?

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
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
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,
https://help.salesforce.com/articleView?id=creating_object_specific_actions.htm&type=0&language=en_US&release=206.13
https://help.salesforce.com/articleView?id=predefined_field_values.htm&type=0&language=en_US&release=206.13
Best Regards,
Yogesh Shete
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "Opportunity",
"defaultFieldValues":{
"Parent_id" : cmp.get("v.Parent_id"),
"Name" : "Test anem",
"AccountId" : cmp.get("v.accountId"),
},
"recordTypeId": cmp.get("v.recordTypeId")
})