0

may I know why this code does not change/update the field object data? By default, the field object (Final_Approved__c) is false. The type is a checkbox. This code is in lightning environment js.

yesButton : function(component,event,helper){
        var result = 'SELECT Id FROM ProcessInstanceWorkitem WHERE processInstance.TargetObjectId=\''+component.get('v.sObjectInfo.Id')+'\'';
        var approvals = component.get('v.queryResult');
        var newRecords = []; 
        if(approvals != undefined && approvals.length > 0){                                 
            var L = new component.get('v.returnShipment');  
            L.id ='Return_Shipment__c.Id';  
            L.Final_Approved__c = true; 
            newRecords.push(L);
            component.set("v.returnShipment",newRecords);
            //window.location.reload();
            var approvalID = approvals[0].Id;
            helper.gotoURL(component, '/p/process/ProcessInstanceWorkitemWizardStageManager?id=' + approvals[0].Id, '_self');

        }
    }
2
  • What are you expecting to happen or what is exactly not working (ex. Aura component doesn't show updated values, backend doesn't show updated values, etc). Apr 8 at 12:39
  • I expect when the user clicks on yesButton, it will update the value(Final_Approved__c) in the backend.
    – Atiqah
    Apr 9 at 0:45
0

From what I can see you aren't calling the server to actually complete an update.

Assuming this is in an Aura or Lightning Web Component, you still need to actually tell the server to update the record, rather than just updating the local version of the record that you have stored within memory.

You'll need an @AuraEnabled apex method to complete the update, or use the Lightning Data Service.

Links: Lightning Data Service: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/data_service.htm Calling a Server-Side Action: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm

Your Answer

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

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