Building a new workflow in CRM. When a new sales order record is created then a custom function inside the workflow is executed which parses the "Subject" field to extract the order number and copies it to a custom field named "Order Number" in the Sales Order module (same module). I have tried many variations of the deluge script below but unable to get past the "Failed to Save the function" message. I admit that it's been several years since I have written any deluge scripts. Any help or direction would be greatly appreciated! Thank you in advance!
// Get the current record ID
recordId = recordId;
// Get the Sales Order record using the ID
sale = zoho.crm.getRecordById("SalesOrders", recordId);
// Get the Subject field from the Sales Order record
sub = sale.get("Subject");
// Split the sub field into words
words = sub.split(" ");
// Get the third word from the subject field
thirdWord = words[2];
// Set the Order Number field to the third word
salesOrder.set("Order_Number", thirdWord);
// Update the Sales Order record with the new Order Number value
updateResp = zoho.crm.updateRecord("SalesOrders", recordId, salesOrder);