1

I'm using lightning:recordEditForm to display the case fields in a component. On clicking next which is present in step 1, it will display another set of values of the same record in step 2. On clicking Previous, it goes back to the first step, but the values I entered before are refreshed and set to old ones.

I want to make those values stay on going back to step 1.

Component

<aura:component implements="lightning:isUrlAddressable,flexipage:availableForAllPageTypes,force:hasRecordId,flexipage:availableForRecordHome" access="global">
<aura:attribute name = "recordId" type = "String"/>
<aura:attribute name = "step" type = "String"/>
<lightning:recordEditForm aura:id="recordViewForm"
                                  recordId= "{!v.recordId}"
                                  recordTypeId="012o0000000uF8n"
                                  objectApiName="Case">
<aura:if isTrue = "{!v.step == '1'}">
  <lightning:inputField fieldName="Root_Sub_Cause__c" aura:id = "rootsubcauseId" variant="label-hidden" />
</aura:if>
<aura:if isTrue = "{!v.step == '2'}">
  <lightning:inputField fieldName="Root_Cause__c" aura:id = "rootcauseId" variant="label-hidden" />
</aura:if>
<lightning:button label = "Previous" variant = "brand" name = "Previous" onclick = "{!c.processToPreviousStep}"/>
                        <lightning:button label = "Save" variant = "brand" name = "Save" onclick = "{!c.processToNextStep}"/>
</lightning:recordEditForm>
</aura:component>

Controller;

processToPreviousStep : function(component, event, helper) {
  component.set("v.step", '1');
},
processToNextStep : function(component, event, helper) {
  component.set("v.step", '2');
}
  • what is present on your step 1 and step 2? How you are differentiating them? Can you add those details as well and improve the code too? – sanket kumar Aug 2 at 13:52
  • @sanketkumar, In step 1 I'm displaying "RootSubCause" field and in step 2 i'm displaying "RootCause" field. When I choose RootSubCause value and goes to step 2 and comes back to step 1 again, the chosen value gone off and restores to its original value. – sfdcOwl Aug 5 at 8:00

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.