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 prodList?

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);
           
            
          
         
        }

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

This seems to be duplicate for the below question.

https://developer.salesforce.com/forums?dc=Apex_Code_Development#!/feedtype=SINGLE_QUESTION_DETAIL&dc=General_Development&criteria=ALLQUESTIONS&id=9062I000000UceP (https://developer.salesforce.com/forums?dc=Apex_Code_Development#!/feedtype=SINGLE_QUESTION_DETAIL&dc=General_Development&criteria=ALLQUESTIONS&id=9062I000000UceP)


Please allow some time for the experts to answer your question as duplicatating the question may cause the duplicate efforts.

Please close this question by marking it as best answer.

Thanks,
 
Elisa FieldsElisa Fields
It should work, check the snippet below, whatever value you enter into text box, it will increment from there only. There might be an issue with parsing in your code.
And try to give a simple code next time which can be understood and run easily. Also your code is complex, try to break it into different module, do not add this much code in one single file.   TellCulvers (https://www.tellculvers.onl/)
function AppViewModel() {

     this.ProductQty = ko.observable(0);

     this.removeFromList = function() {
       var currentVal = parseInt(this.ProductQty());
       if (currentVal >= 1) {
         this.ProductQty(currentVal - 1);
       }
     };

     this.addToCartViaOrderList = function() {
       var currentVal = parseInt(this.ProductQty());
       if (isNaN(currentVal)) {
         currentVal = 0;
       }
       this.ProductQty(currentVal + 1);
     };
   }

    // Activates knockout.js
   ko.applyBindings(new AppViewModel());
 
.qty {
  font-size: 38px;
}
a {
  text-decoration: none;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js"></script>
<div class="qty">
  <a href="#">
    <label data-bind="click: $root.removeFromList">-</label>
  </a>
  <input type="text" data-bind="value: ProductQty" />
  <a href="#">
    <label data-bind="click: $root.addToCartViaOrderList">+</label>
  </a>
</div>

 
Robert A. EliasRobert A. Elias
    Nice and amazing post this one is, thanks for sharing…
Dinar Guru (https://www.dinarguru.biz/)