Workflow Tips: Start with a Timer Activity
It’s beginning to be a well known tip, but I’m surprised at how many people still don’t know about this simple trick!
The trick is to include a 1 second timer activity at the beginning of your workflow, or anywhere after a user interaction can happen (approvals, close task, etc).
The way this works is that workflows are started typically based on a user interaction, and then the first activity runs as the user in the user’s session. Depending on the script executed, this can run long on the user session causing a bad experience where the user has to wait on the activity to finish executing. By adding the one second timer it instead breaks off from the user session and queues the workflow to run in the background as a scheduled job.
Besides running in the background, another key benefit is that the scheduled job is run by a system user. This can also sometimes resolve some access errors, and for updates that occur, it will be written to the activity log as the System Administrator instead of the actual user who kicked off the workflow activity.
On the flip side, it’s also considered bad practice to have to many timer activities, and activities in the workflow in general, so it’s good to use this tip in moderation!
ServiceNow KB covering the topic: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0647534