Deluge script executes but doesn't update record?
I have worked/researched all day trying to get this to work but the record doesn't update. The script executes successfully. I could use some insight and direction. Maybe I'm not approaching this right or some part of my code is incorrect?
Here are details and script
- Building a workflow that has a custom instant action function ( I will add a 10 min delay on it after successful transfer of data is achieved).
- The goal is to populate a lookup field named Sales_Order in a custom module named Patients upon new patient record creation that associates the Patient record with the correct Sales Order
- Both Modules have identical order number fields and they both contain the same number. So the script uses that criteria to search the Sales_Orders records to find the match
- If there is a match (always should be) then copy the "Subject" field from the matching Sales Order module record and put it in the matching Patient module lookup field Sales_Order which creates the correct association
- I already created the argument mapping "patient_record_id = Patients - Patient Id"
- // Get the Order_Number field from the Patients module
- patient_record = zoho.crm.getRecordById("Patients", patient_record_id);
- order_number = patient_record.get("Order_Number");
- // Search the Sales_Order module for a matching Order_Number
- sales_orders = zoho.crm.searchRecords("Sales_Orders", "Order_Number:equals:" + order_number);
- // If a match is found, get the Subject field of the matching Sales_Order record
- if(sales_orders.size() > 0) {
- sales_order_record = sales_orders.get(0);
- sales_order_subject = sales_order_record.get("Subject");
- // Update the Sales_Order field of the Patients module with the matching Sales_Order subject
- update_data = Map();
- update_data.put("Sales_Order", sales_order_subject);
- update_response = zoho.crm.updateRecord("Patients", patient_record_id.toLong(), update_data);
- }