function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LUIGI EMANUEL TAORMINALUIGI EMANUEL TAORMINA 

How do I update a record in the List?

Hi,this function takes as input a value (Quantity) this value must be subtracted from the value of the Available Quantity field contained in the "prodList" list filtered by the id, with the result of the subtraction "rquantity" must be inserted (update) in the list " v.prodList "passing the id. How can it be done?


Controller
yesBtn : function(component,event,helper){
        var qty=component.find("prova").get("v.value");
        var name=component.get("v.Name");
        var cr=component.get("v.id");
        var aquantity=component.get("v.AQuantity");
        console.log("id book "+component.get("v.id"));
        if(qty>aquantity){
            var toastEvent = $A.get("e.force:showToast");
            toastEvent.setParams({
                title : 'Error',
                message: 'the quantity you want exceeds that available',
                duration:' 5000',
                key: 'info_alt',
                type: 'Error',
                mode: 'pester'
            });
            toastEvent.fire();
        }
        else{
            var rquantity=aquantity-qty;
            console.log("Available quantity - quantity = " +rquantity);
       console.log("List"+ component.get("v.prodList"));
            
          
         
        }