You need to sign in to do that
Don't have an account?
Henry Michel
I have to override the standard new button.
I have an overridden standard 'New' button in lightning with my custom component but when I am using it from the related list of the parent object, I am not getting parent record id in the URL. Also, 'hasRecordId' is giving Id of the child record only. Any Solution for this??
Firstly, you need to implement 'lightning:isUrlAddressable' in your component and then use below piece of code according to your requirement.
Also, go to the below link to know more about 'lightning:isUrlAddressable':
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation
var ref = c.get("v.pageReference");
var state = ref.state;
var context = state.inContextOfRef;
if (context.startsWith("1\.")) {
context = context.substring(2);
var addressableContext = JSON.parse(window.atob(context));
console.log('addressableContext----->'+JSON.stringify(addressableContext)); // you can get your recordId and other things here.
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
All Answers
Firstly, you need to implement 'lightning:isUrlAddressable' in your component and then use below piece of code according to your requirement.
Also, go to the below link to know more about 'lightning:isUrlAddressable':
https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation
var ref = c.get("v.pageReference");
var state = ref.state;
var context = state.inContextOfRef;
if (context.startsWith("1\.")) {
context = context.substring(2);
var addressableContext = JSON.parse(window.atob(context));
console.log('addressableContext----->'+JSON.stringify(addressableContext)); // you can get your recordId and other things here.
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
I'm also trying to imlement the similar functionlity. but when i click new button in related list, It opens a new tab and displaying a popup window. But I'm not able to close that tab. can you please let me know if you have face this issue or help me in resolving this.
Thank,
Mano