Zoho CRM Org Variable not up to date on zoho.crm.getOrgVariable call

Zoho CRM Org Variable not up to date on zoho.crm.getOrgVariable call

Hi, 

I have encountered a fundamental problem when updating an org variable and getting it back using zoho.crm.getOrgVariable. 

I have this code: 
Invoice_Test_Var = zoho.crm.getOrgVariable("Invoice_Test_Var").toLong();
valueMap = Map();
valueMap.put("apiname","Invoice_Test_Var");
lngNewXeroInvoice = Invoice_Test_Var + 1;
valueMap.put("value",lngNewXeroInvoice);
info "valueMap is:" + valueMap;
resp = zoho.crm.invokeConnector("crm.set",valueMap);
info "*** (1) The response after setting the var is: " + resp;
Invoice_Test_Var_After = zoho.crm.getOrgVariable("Invoice_Test_Var").toLong();
info "*** (2) The response after calling zoho is: " + Invoice_Test_Var_After;

The console log is:
  • valueMap is:{"apiname":"Invoice_Test_Var","value":9}
  • *** (1) The response after setting the var is: {"status_code":"200","response":"{\"Invoice_Test_Var\":\"9\",\"message\":\"New value updated successfully.\"}"}
  • *** (2) The response after calling zoho is: 8
  • Function executed successfully

  • As you can see, the response after setting the org variable is successful, however, when getting the variable back from zoho, it returns the previous value of that variable i.e it appears that it takes time to update it. This happens about 20% of the time which makes it very unreliable to use as this value should always be unique. It is used in a function that creates a series of records/lines and assigns this unique number to each.
  • Could you please advise on why it is happening and a fix to this issue.  Also, would be nice to explain why the response after setting the variable differs from the variable returned from the API call.
  • Alternatively, is it reliable to use the value from the response after setting the variable?

  • Thanks!