Custom field update from Deluge custom function giving permission error
Hello,
We are trying to create a
custom function which will sum the total quantity of all line items on a
Sales Order and output this to a custom field on the Sales Order. We
have a custom field called "Sum of Line Items" which is a Number type
and is a Default Value of 0 (API Field Name is cf_sum_of_line_items).
The custom function is written inside of Deluge with Sales Order as the
Module chosen:
salesorderID = salesorder.get("salesorder_id");
organizationID = organization.get("organization_id");
sumOfLineItem = 0;
// Loop through line items and add sum to total
allLineItems = salesorder.getJSON("line_items");
for each lineItem in allLineItems
{
lineItemQty = lineItem.get("quantity");
sumOfLineItem = sumOfLineItem + lineItemQty;
}
info sumOfLineItem;
// Create List for Custom Fields update
CustomFields = List();
CustomField = Map();
CustomField.put("label","Sum of Line Items");
CustomField.put("value",sumOfLineItem);
CustomFields.add(CustomField);
soUpdate = Map();
soUpdate.put("custom_fields",CustomFields);
response = zoho.inventory.updateRecord("SalesOrders",organizationID,salesorderID,soUpdate);
info response;
When we execute this code as an Admin user through the Custom Function script edit screen we receive the following response output:
{"code":57,"message":"You are not authorized to perform this operation"}
The
sumOfLineItem reports correctly but it will not update the record's
custom field "Sum of Line Items" from 0 to 16 (as an example).
My
understanding is that working within Automation > Custom Functions
and coding in Deluge does not require an explicit API connection to work
on this update. Is that correct? And is the custom_fields area the
correct list to update or is custom_field_hash the one I should be
attempting to update? (attempts to update both result in the code 57).
What syntax or update method is incorrect in this code?
Thank you,
Curtis
Sticky Posts
Zoho Inventory will discontinue support for older browser versions soon
Hello users, Starting from May 15, 2024, Zoho Inventory will no longer support the following browser versions: Browsers Version Restrictions Firefox Browser Versions older than 100 Google Chrome Versions older than 100 Microsoft Edge Versions older than
Zoho Finance Workshop 2023 is coming to the USA. Meet the experts, get exclusive training on Zoho Finance apps and more.
Hello all, We'd like to invite you to our biggest Zoho Finance workshop in the United States. After a brief break, we are excited to be back. This year, we're bringing together our customers and community members for two days of curated hands-on sessions,
Celebrating our Zoho Community SuperBuds
The SuperBud program recognizes the efforts Zoho users put in to help the rest of the community thrive and grow in their individual Zoho journeys. Be it the ZUG meetups or these forums, several Zoho users including our MVPs andZUG leaders, have stepped
Authtoken Deprecation for Zoho Inventory APIs
UPDATE (7 July 2021): We've extended the deadline to 30 August 2021 for converting Authtokens to OAuth. Hello everyone, The usage of Authtokens to authenticate API calls is being deprecated on 30 August 2021 across Zoho's Finance suite of products,
ZOHO Inventory - Early Access
https://twitter.com/zoho/status/646715717849493504