Batches Online
Hello!
I am trying to figure out how to write handle batches in CRMScript for the online version of SuperOffice. I am trying to update a custom field on all contacts in my database using a few if-statements, but the database is too large for me to be able to run it all at once. The problem is that I want this code to run once a week, without me having to go into the script, tell the code to run the first 100 companies, then the next 100 companies and so on. Is there any way for me to be able to create a shedueled task each week, and tell the schedule to run one script many times, and for the database to somehow know how many times the script has run, and therefore how many companies it has completed before, and how many times it should run again? Below is some pseudocode for how I wish for it to run, but I don't know how to actually write the code or if it is even possible:
SearchEngine se;
se.AddField(Information about all companies);
se.setLimit(100);
se.criteria(currentCustomerId > lastHandeledId) //This is where the problem lies
se.execute();
and then some code for changing the custom fields based on the information
Is this possible at all, and how?
Thank you in advance.
Alles Antwoorden (1)
Hi Beata,
if a customer has development tools so you can actually write CRMScript, it also means they also have the subscription needed to create custom apps and you can use the WebAPI directly:
https://docs.superoffice.com/en/api/netserver/bulk-operations/index.html
https://docs.superoffice.com/en/api/netserver/search/odata/index.html
It's a lot faster since the CRMScript code actually gets translated into the same archives behind these API calls when executed
https://docs.superoffice.com/en/api/netserver/search/odata/index.html
Other benefits of using the APIs instead of the CRMScripts:
- If it fails you will see the exceptions linked to your apps credentials inside the developer portal: https://docs.superoffice.com/en/developer-portal/analytics/failures.html
- You are not limited by the 2 min timeout we have on CRMScripts running in our Online environment.
More info on what you can do with CRMScript and its limitations: https://docs.superoffice.com/en/automation/crmscript/overview/crmscript-usage.html