0

I am having the Lightning component that uses the Lightning Data Services to update the fields on the Case record, it works fine if the component is updating fields like status or origin like that. But when I try to update the record type/owner the page is not refreshed after the update happens.

Below is the component where I am updating the record type and Owner basically it is like transfering the case from one Dept to another

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"  >
<aura:attribute name="loaded" type="Boolean" default="false" />
<lightning:spinner variant="brand" alternativeText="Loading..." class="{!(v.loaded? 'slds-show': 'slds-hide')}" />
 <lightning:recordEditForm aura:id="form" 
        objectApiName="Case" 
        recordId="{!v.recordId}"
        onsubmit="{!c.handleSubmit}"
        onerror="{!c.handleError}"
        onsuccess="{!c.handleSuccess}">
        <lightning:inputField aura:id="statusInput" fieldName="Status" class="slds-hide" />
        <lightning:button variant="brand" type="submit" label="SF Support" />
 </lightning:recordEditForm>    
</aura:component>

Controller

({
    handleSubmit: function(component, event, helper) {
        component.set('v.loaded',true);
        event.preventDefault();      
        var fields = event.getParam('fields');
        
        fields.OwnerId = 'xxxxxxxxxx'; // Owner is SF Support           
        fields.RecordTypeId = 'YYYYYYYYYYYYY';
        fields.Status = 'New';
        console.log(JSON.stringify(fields)); 
        component.find('form').submit(fields);
        
    },
    
    handleError: function(component, event, helper) {
        component.set('v.loaded',false);
        const fieldErrors = event.getParam('output').fieldErrors;
        const separator = ' ';
        
        let errMessage = Object.values(fieldErrors).map(field => {
            return field.map(error => error.message).join(separator);
        }).join(separator);
        
        $A.get("e.force:showToast")
        .setParams({
            type: 'error',
            mode: 'pester',
            message: errMessage  }).fire();       
    },
    
    handleSuccess: function(component, event, helper) {
        component.set('v.loaded',false);
        $A.get("e.force:showToast")
        .setParams({
            type: 'success',
            message: 'Case passed to Salesforce Support!',
            mode: 'pester'
        })
        .fire();
    }
})

Though the Owner/RecordType is updated the page is not refreshed. Below screesnshot shows the page is not refreshed , I should be seeing the Owner as SF Support but it still shows the old owner Services but Toast is fired saying the case is passed.

enter image description here

But when do the full page refresh it shows up SF Support. Can anyone please help me what I am missing here

8
  • The code does refresh the owner value for me. The detail component is the standard component or you have custom detail component? Oct 7 '20 at 5:16
  • It is the standard component, when the button is clicked it freezes the screen for sometime and doesnt let me refresh the browser
    – user81642
    Oct 7 '20 at 12:12
  • @sanketkumar Did you change the record type as well when you tried ?
    – user81642
    Oct 7 '20 at 12:59
  • yes, i have tried both and worked perfectly fine. Oct 7 '20 at 14:21
  • Do you think any reason for this behavior I am seeing. Is it safe to use the .reload() with the controller on the handlesuccess?
    – user81642
    Oct 7 '20 at 14:32

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.