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

Create new Contact from Account detail Related List (Lightning Component)
Original question:
I have overriden my standard newContact page with a custom lightning component bundle. The reason i did this is to avoid standard salesforce fields like account phone getting auto populated when creating a contact through Account related list.
I utilized force:createRecord event and have resolved almost all of the issues except for only 1 which i am stuck and need to get it resolved.
Problem: The problem is that in my component i am retrieveing accountId and recordTypeID. When i click on an account i ended up on the detail page. Now when i click new contact from account detail related list, it invokes my lightning component which basically fires force:Createrecord event. Since i came from the account detail page, my parent window should be account detail page also but it is not. It basically hovers over to an empty 'Contacts' tab. This is because the window URL has changed.
Original URL before creating new contact from account detail page:-
https://*.force.com/one/one.app#/sObject/001f400000AdMNOAA3/view
After clicking new contact :-
https://*.force.com/one/one.app#/sObject/Contact/new?recordTypeId=012f4000000DzRj&additionalParams=accid%3D001f400000AdMNO%26
My question is that is there any way i can take the user back to account detail page if he/she closes the modal dialog or click cancel ? or can i capture that event so i can invoke some JS function to redirect user to the correct page ? Please find my small test code below
ContactComponent.cmp
<aura:component implements="force:lightningQuickAction,lightning:actionOverride,force:hasRecordId,flexipage:availableForAllPageTypes,force:appHostable" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="accid" type="Id" />
<aura:attribute name="recordTypeId" type="Id" />
</aura:component>
ContactComponentController.js
({
init : function(component, event, helper) {
console.log('insideinit');
var createAcountContactEvent = $A.get("e.force:createRecord");
console.log('Account ID after action is ' + accId);
createAcountContactEvent.setParams({
"entityApiName": "Contact",
"defaultFieldValues": {
'Phone' : ''
}
});
createAcountContactEvent.fire();
}
})
I have overriden my standard newContact page with a custom lightning component bundle. The reason i did this is to avoid standard salesforce fields like account phone getting auto populated when creating a contact through Account related list.
I utilized force:createRecord event and have resolved almost all of the issues except for only 1 which i am stuck and need to get it resolved.
Problem: The problem is that in my component i am retrieveing accountId and recordTypeID. When i click on an account i ended up on the detail page. Now when i click new contact from account detail related list, it invokes my lightning component which basically fires force:Createrecord event. Since i came from the account detail page, my parent window should be account detail page also but it is not. It basically hovers over to an empty 'Contacts' tab. This is because the window URL has changed.
Original URL before creating new contact from account detail page:-
https://*.force.com/one/one.app#/sObject/001f400000AdMNOAA3/view
After clicking new contact :-
https://*.force.com/one/one.app#/sObject/Contact/new?recordTypeId=012f4000000DzRj&additionalParams=accid%3D001f400000AdMNO%26
My question is that is there any way i can take the user back to account detail page if he/she closes the modal dialog or click cancel ? or can i capture that event so i can invoke some JS function to redirect user to the correct page ? Please find my small test code below
ContactComponent.cmp
<aura:component implements="force:lightningQuickAction,lightning:actionOverride,force:hasRecordId,flexipage:availableForAllPageTypes,force:appHostable" access="global">
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="accid" type="Id" />
<aura:attribute name="recordTypeId" type="Id" />
</aura:component>
ContactComponentController.js
({
init : function(component, event, helper) {
console.log('insideinit');
var createAcountContactEvent = $A.get("e.force:createRecord");
console.log('Account ID after action is ' + accId);
createAcountContactEvent.setParams({
"entityApiName": "Contact",
"defaultFieldValues": {
'Phone' : ''
}
});
createAcountContactEvent.fire();
}
})
As per my best knowledge No, you can not do this while overriding the button using lightning bundle. But as an alternative, you can use the same component as Quick action into Account Detail page which will also keep the track of account page and will resolve the issue if you can do that.
Hope this helps.
Thanks,
Nagendra
All Answers
As per my best knowledge No, you can not do this while overriding the button using lightning bundle. But as an alternative, you can use the same component as Quick action into Account Detail page which will also keep the track of account page and will resolve the issue if you can do that.
Hope this helps.
Thanks,
Nagendra
Cheers !
Hai Nagendra,
Can you please share me code for Quick Action Related List. and is possible to write Custom Sort Button or Drag and Drop that Recors using Lightning component Code