custom function in Products module unable to update "Quantity in Stock" field

custom function in Products module unable to update "Quantity in Stock" field

Good day,

My business scenario is that my Products are in three different warehouses. The warehouse employees will input the product quantity present in each warehouse. I would like Zoho to update the field "Quantity in Stock" with the sum of these three quantities. That way, all my mobile salespeople can see the total quantity available. And when they make a sale, Zoho will subtract the quantity sold from "Quantity in Stock", so we don't sell products we don't have.

I created three custom fields on Product (one to keep the quantity at each warehouse) and wrote a custom function (see screenshot attached) to update "Quantity in Stock". It does not update "Quantity in Stock", but if I try to update another custom field instead, it works perfectly. Why is the "Quantity in Stock" field special?

If it is not possible to update "Quantity in Stock" via a custom function, do you have another suggestion to achieve same?

Thanks for any suggestions.