// Update the Items custom field cf_textarea with a short random string
salesorderID = salesorder.get("salesorder_id");
// Get the line items of the sales order
items = salesorder.get("line_items");
// Iterate through each item and update cf_textarea
itemLis = List();
for each item in items
{
// get item id
itemId = item.get("item_id");
// Generate a short random string (e.g., 9 characters)
myList = {0,1,2,3,4,5,6,7,8,9,10,11,12};
passString = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
newList = "";
for each index i in myList
{
randnum = randomNumber(1,62);
newList = newList + substring(passString,randnum,randnum + 1);
}
unique_pass = replaceAll(newList,",","");
// info unique_pass;
// Update the cf_textarea field of the item
itemmap = Map();
itemmap.put("item_id",itemId);
Linecfs = List();
cf = Map();
cf.put("api_name","cf_textarea");
cf.put("value",unique_pass);
Linecfs.add(cf);
itemmap.put("custom_fields",Linecfs);
itemLis.add(itemmap);
info itemmap;
response = zoho.inventory.updateRecord("Items","organisation_id",itemId,itemmap,"zom");
}
info response;