You need to sign in to do that
Don't have an account?
Navin Ganeshan 10
aura: populate account when creating contact from account related list
Hi,
Looking from some guidance on how to pre-populate account id on a custom aura component to create contacts.
I would like to pre-populate account id on the component, when a user clicks on "New Contact", on Account's related contact list. I have declared "force:hasRecordId on the component. but nothing is returned for recordId:
Any idea why this would not work from related page?
Thanks,
Navin
Looking from some guidance on how to pre-populate account id on a custom aura component to create contacts.
I would like to pre-populate account id on the component, when a user clicks on "New Contact", on Account's related contact list. I have declared "force:hasRecordId on the component. but nothing is returned for recordId:
<aura:component implements="force:lightningQuickAction,force:hasRecordId"> <lightning:input value={!v.recordId} </aura:component>However, this does work when i add new contact button to Account's record detail page.
Any idea why this would not work from related page?
Thanks,
Navin
force:hasRecordId interface will works only if the custom component is used on a Lightning record page. But the same won't work for the related list.
As an alternate you can use the lightning:isUrlAddressable and Pagerefence in lightning. Please refer the below sample codes.
https://sfdclesson.com/2019/11/23/get-parent-record-id-from-lightning-url/
Example :
Thanks,
Maharajan.C
All Answers
>> https://developer.salesforce.com/forums/?id=9060G0000005SiCQAU
I have found the above thread that has a similar implementation and I added a line to show the Record Id, it is in bold. You can use the below code to prepopulate the account id on click of a custom create contact button:
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
force:hasRecordId interface will works only if the custom component is used on a Lightning record page. But the same won't work for the related list.
As an alternate you can use the lightning:isUrlAddressable and Pagerefence in lightning. Please refer the below sample codes.
https://sfdclesson.com/2019/11/23/get-parent-record-id-from-lightning-url/
Example :
Thanks,
Maharajan.C
Thanks,
Maharajan.C