Custom Function CF Field Update
I'm new to Zoho and Deluge, so please forgive my naivety.
I'm trying to create a customer function which updates two custom fields on an inventory item.
The code runs fine, and the info response show the correct value, however the fields in the items do not update.
The script I have written is below. Any suggestions as to what is causing the record not to update would be hugely welcome. Thanks in advance.
itemID = item.get("item_id");
organizationID = organization.get("organization_id");
purchaseprice = todecimal(item.getJSON("purchase_rate"));
sellprice = todecimal(item.getJSON("rate"));
margin = tolong((sellprice - purchaseprice) / sellprice).round(2);
grossprofit = tolong(sellprice - purchaseprice);
myitem= Map();
myitem.put("cf_margincalc",grossprofit);
myitem.put("cf_marginpercentage",margin);
response = zoho.books.updateRecord("Items",organizationID,itemID,myitem,"zbooks");
info response;