Iteration through a list - Coming up against a "Failure to update function" error

Iteration through a list - Coming up against a "Failure to update function" error

Hi there! I've been attempting to get a deluge script working and am running into an error that I have been unable to resolve. The error I am getting is

  1. Failed to update function
  2. Error at line :18. Improper Statement. Error might be due to missing ';' at end of the line or incomplete expression Line Number : 16Failed to update function
  3. Error at line :18. Improper Statement. Error might be due to missing ';' at end of the line or incomplete expression Line Number : 16

Here is my script:

  1. // Organization ID
  2. OrgID = xxxxxxxxxx;

  3. //Input parameters - Retrieve record and account info and consultant full name from account. Write team ID to variable.
  4. record = zoho.desk.getRecordById(OrgID,"tickets",ticket_id);
  5. account = zoho.desk.getRecordById(OrgID,"accounts",schools_id);
  6. customer_success_consultant = account.get("cf").get("cf_custome_success_consultant");
  7. team_id = 19368xxxxxxxxxxxx; //Hardcoded permanently - Value never changes

  8. //Initialise loop variables
  9. index_value = 0;
  10. page_size = 10;
  11. iterations = 100; //increase this number if we ever have more than 1000 agents in Zoho. This will scan through iterations x 10 records.
  12. iterationString = "".leftPad(iterations).replaceAll(" ",",").toList().subList(0,iterations);

  13. for each iteration in iterationString{
  14. //fetch records in batches of 10
  15. user_records = zoho.desk.getRecords(OrgID, "agents", index_value, page_size,{"searchStr":customer_success_consultant});
  16. resp = user_records.getJson("data");
  17. resp_list = resp.toJSONList();

  18. //Exit loop if no records are found
  19. if (resp_list.isEmpty()){
  20. info "No more records to process. Exiting loop";
  21. break;
  22. }

  23. //Process the returned record if found
  24. if (!resp_list.isEmpty()){
  25. for each user in resp_list
  26. {
  27. if(user.get("name") == customer_success_consultant)
  28. {
  29. user_id = user.getJson("id");
  30. info "User found!";
  31. }
  32. }
  33. index_value = index_value + page_size;
  34. }

  35. }

  36. record_value = {"teamId":team_id,"assigneeId":user_id};
  37. update_ticket = zoho.desk.update(OrgID,"tickets",ticket_id,record_value);
I had this successfully working before attempting to iterate through pages of results, so I know the query to retrieve agents and the ticket update functions on lines 43 and 44 work - I just cannot get the iteration to progress.

Any assistance would be greatly appreciated!