• SULEMAN ZIA
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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(); 
    }
}) 
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(); 
    }
})