I have implemented a custom lightning component with recordEditForm and updating opp stagename which accidentally refreshing the page but when i remove stagename input field from the form its working fine and not refreshing the page.

please help this is urgent.

Thanks,

Component Code -

<aura:attribute name="record" type="Opportunity"/>
<aura:attribute name="simpleRecord" type="Opportunity"/>
<aura:attribute name="recordError" type="String"/>

{!v.saved}

<force:recordData aura:id="recordLoader"
  recordId="{!v.recordId}"
  targetFields="{!v.simpleRecord}"
  targetError="{!v.recordError}"
  recordUpdated="{!c.handleRecordUpdated}"
  fields="Name"
  />

<!-- Display a lightning card with details about the record -->
<div class="Record Details"> 
<lightning:card iconName="standard:opportunity" title="{!v.simpleRecord.Name}" >
    <div class="slds-p-horizontal--small">
        <p class="slds-text-heading--small">
            <lightning:formattedText title="Billing City" value="{!v.simpleRecord.Name}" /></p>
        <p class="slds-text-heading--small">
            <lightning:formattedText title="Billing State" value="{!v.simpleRecord.StageName}" /></p>
    </div>
</lightning:card>
</div>

<!-- Display Lightning Data Service errors, if any -->
<aura:if isTrue="{!not(empty(v.recordError))}">
    <div class="recordError">
        {!v.recordError}</div>
</aura:if>

<aura:if isTrue="{!!v.saved}">
    <lightning:recordEditForm
        aura:id="submitform"
        onsubmit="{!c.handleSubmit}"
        onsuccess="{!c.handleSaveStage}"
        recordId="{!v.recordId}"
        objectApiName="Opportunity">
        <!-- the messages component is for error messages -->
        <lightning:messages />

        <div class="slds-m-top_medium">
            <lightning:button disabled="{!v.disabled}" variant="brand" type="submit" name="save" label="Save" />
        </div>

        <lightning:inputField fieldName="Name" />
        <lightning:inputField fieldName="StageName" />
        <lightning:inputField fieldName="Annuity_Project__c" />
        <lightning:inputField fieldName="Deal_Administrator__c" />

    </lightning:recordEditForm>
    <aura:set attribute="else">            
        <p>Saved!!</p>
    </aura:set>
</aura:if>

<aura:if isTrue="{!v.Spinner}">
    <div aura:id="spinnerId" class="slds-spinner_container">
        <div class="slds-spinner--brand  slds-spinner slds-spinner--large slds-is-relative" role="alert">
            <span class="slds-assistive-text">Loading</span>
            <div class="slds-spinner__dot-a"></div>
            <div class="slds-spinner__dot-b"></div>
        </div>
    </div>
</aura:if>

Controller -

handleSubmit : function(component, event, helper){
     event.preventDefault();
     component.find("submitform").submit();
     //helper.showSpinner(component, event, helper);
},

enter image description here

  • Do share the relevant code as well. – itzmukeshy7 Dec 5 at 5:23
  • Please see code updated above and also this work properly when i use this in separate app but when i embed this component on Opportunity record page and submit the form it refresh and when i comment this LOC (stagename) it work properly. – Dildar Hussain Dec 5 at 5:48
  • Try force: refreshView in the success callback. – itzmukeshy7 Dec 5 at 6:08
  • Is whole page refreshing or only a view refreshing? – vignesh Dec 5 at 7:14
  • not the whole browser but content view page and it gets blank. Please see the screenshot. – Dildar Hussain Dec 5 at 10:52

Just thanks to all for your suggestions. I got the root cause of the issue and that was, in the background some old code was executing and changing recordtype which also change the page layout. Now once i inactive that workflow rule its working nice.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.