The VF page has a redirect action which redirects to a lightning component which opens the record in edit mode. VF Page code -

<apex:page standardController="ZTS_EU_Affiliations__c" extensions="ZTS_US_accountContactAffController" action="{!doRedirect}" id="thePage">

the code written in doRiderct function is -

public PageReference doRedirect()
    //if is INTL AccContactAffiliation then do Edit view 
    if (accConAff.ZTS_EU_Market_from_Parent__c != 'United States' && editFunc) {
        try {
            String returnUrl = '/lightning/cmp/c__EditAccContAffIntl?c__recordId='+accConAff.Id;
            PageReference pgReturnPage = new PageReference(returnUrl);
            return pgReturnPage;
        } catch(Exception e) {
            System.debug('The following exception has occurred: ' + e.getMessage());
            return null;
    else {
        renderButton = true;
        return null;

Below is the component code: component:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,lightning:isUrlAddressable,lightning:hasPageReference" >
<aura:attribute name="recordId" type="String" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="change" value="{!v.pageReference}" action="{!c.doInit}" />
    <lightning:spinner alternativeText="Loading" size="medium" variant="brand" />
<lightning:navigation aura:id="navService"/>


    doInit : function(component, event, helper) {

        var myPageRef = component.get("v.pageReference");
        var templateId = myPageRef.state.c__recordId;
        helper.doEditAffiliationEvt(component, event, helper);



    doEditAffiliationEvt : function(component, event, helper) {
        var recordId = component.get("v.recordId");
        var pageReference = {    
            "type": "standard__recordPage",
            "attributes": {
                "recordId": recordId,
                "actionName": "view"

        var navService = component.find("navService");
        pageReference.attributes.actionName = "edit";

Now issue is when I am editing a record of market != 'United States' it is not opening any page in edit mode, rather it is toggling between 2 URLS, URL bar goes crazy-

  1. https://touchpointeca--lightuat.lightning.force.com/lightning/r/ZTS_EU_Affiliations__c/a0P2A00000bRMWNUA4/view?nooverride=1
  2. https://touchpointeca--lightuat.lightning.force.com/lightning/r/ZTS_EU_Affiliations__c/a0P2A00000bRMWNUA4/edit?nooverride=1&backgroundContext=%2Flightning%2Fcmp%2Fc__EditAccContAffIntl%3Fc__recordId%3Da0P2A00000bRMWNUA4

Can you please check the component code and let me know where is the issue?

  • having 2 calls of navService.navigate() might be the issue. Comment out one of them and check if that fixes the problem – Nagen Sahu Oct 20 '20 at 7:45
  • If I comment out 1st navigate statement, the URL becomes stable, and record is opened in Edit mode. but after editing the record it is not opening the record in view mode. the modal is closed, and spinner starts spinning. – Aritra Chakraborty Oct 21 '20 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.