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
- Failed to update function
- 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
- 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:
- // Organization ID
- OrgID = xxxxxxxxxx;
- //Input parameters - Retrieve record and account info and consultant full name from account. Write team ID to variable.
- record = zoho.desk.getRecordById(OrgID,"tickets",ticket_id);
- account = zoho.desk.getRecordById(OrgID,"accounts",schools_id);
- customer_success_consultant = account.get("cf").get("cf_custome_success_consultant");
- team_id = 19368xxxxxxxxxxxx; //Hardcoded permanently - Value never changes
- //Initialise loop variables
- index_value = 0;
- page_size = 10;
- iterations = 100; //increase this number if we ever have more than 1000 agents in Zoho. This will scan through iterations x 10 records.
- iterationString = "".leftPad(iterations).replaceAll(" ",",").toList().subList(0,iterations);
- for each iteration in iterationString{
- //fetch records in batches of 10
- user_records = zoho.desk.getRecords(OrgID, "agents", index_value, page_size,{"searchStr":customer_success_consultant});
- resp = user_records.getJson("data");
- resp_list = resp.toJSONList();
- //Exit loop if no records are found
- if (resp_list.isEmpty()){
- info "No more records to process. Exiting loop";
- break;
- }
- //Process the returned record if found
- if (!resp_list.isEmpty()){
- for each user in resp_list
- {
- if(user.get("name") == customer_success_consultant)
- {
- user_id = user.getJson("id");
- info "User found!";
- }
- }
- index_value = index_value + page_size;
- }
- }
- record_value = {"teamId":team_id,"assigneeId":user_id};
- 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!