Same flow triggered by multiple records at the same time resulting in incorrect update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2025 02:01 AM
Hi Everyone,
We have a flow which runs on sc_task table and in one of the steps the flow is checking if the allocations available on an alm_license record then it will reduce the allocations by 1. This functionality is working fine but it doesnt work correctly when the same flow if triggered by multiple records at the same time to update the same alm_license record.
For e.g. If the allocations available are 2 and 10 records trigger the same flow within few secs and trying to update the same alm_license record, for all 10 records it checks allocations available > 0 condition at the same time so for all 10 tasks the condition satisfies and they all reduce the allocations available by 1 so allocations available goes to -8 which shouldnt happen.
How to prevent parallel flow execution to prevent such scenario?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2025 05:08 AM
Thank you for marking my response as helpful.
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2025 06:41 AM
Solution:
Replace your Flow Designer update action with a Run Script action containing:
javascript(current)
var license = new GlideRecord('alm_license');
license.setWorkflow(false);
if (license.get('sys_id', inputs.license_sys_id)) {
if (license.getValue('allocations_available') > 0) {
license.allocations_available = parseInt(license.allocations_available) - 1;
license.update();
outputs.success = true;
} else {
outputs.success = false;
}
}
setWorkflow(false) prevents recursive flow triggers, and the atomic read-modify-write operation in a single script prevents race conditions. The database row lock during get() and update() ensures concurrent executions process sequentially.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2025 02:14 AM
@MaxMixali : Thanks for your reply. If two flows are triggered at the same time updating the same record, Which statement/part of code here will prevent the another flow execution from running in parallel?
Could you please explain, as I didn't get it exactly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2025 02:18 AM
How It Works
When a flow executes an Update Record action:
- ServiceNow acquires a database row lock on that specific record
- This lock is held for the entire duration of the update transaction
- Any other flow/process trying to update the same record must wait until the lock is released
- The second flow then proceeds with its update based on the current state of the record (which now includes changes from the first flow)
No Specific Code Required
I hope it's. ore clear now
