How do I make custom function to execute first then create task in blueprint?

How do I make custom function to execute first then create task in blueprint?

I have this custom function that autocomplete open task. I want to autocomplete any open task anytime I click the next state. the problem is any task I auto created in the next state ended up as complete. I figured the problem must be because after clicking the the next state, the blueprint create task first and then execute the custom function. Is there anyway to make the custom function executed first upon clicking the next state?

the only alternative solution I can think of is creating a custom function for each state and auto complete task only created in previous state. but this solution is tedious and I'm looking if there is any better way to do this.

attached blueprint screenshot and custom function used:


  1. rLeads = zoho.crm.getRelatedRecords("Activities","Leads",lId);
  2. info rLeads;
  3. for each  record in rLeads
  4. {
  5.     recordId = record.get("id").toNumber();
  6.     info recordId;
  7.     if(record.get("Status") != "Completed")
  8.     {
  9.         recordMap = Map();
  10.         recordMap.put("Status","Completed");
  11.         info recordMap;
  12.         updateRecord = zoho.crm.updateRecord("Tasks",recordId,recordMap);
  13.         info updateRecord;
  14.     }
  15. }