- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2020 07:29 PM
Hi,
With 'created or updated' trigger and run trigger as 'only if not currently running', once a flow is triggered and moves into 'wait for duration of time after' state (waiting for start date) , Now if record is updated e.g. start date is updated, the flow runtime value in wait for duration step is not updated, shows original start date value.
Not sure if this is FD limitation in NY release..how can I update the runtime value or update/restart the flow with new updated record?
Thanks!
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-09-2020 08:50 PM
You cannot re-run the flow.
So cancel the previous context and start new one.
You can start the flow again via script possibly after update BR when Start Date is Updated
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec = new GlideRecord('sys_flow_context');
rec.addQuery('name','Flow Name Here');
rec.addQuery('source_record', current.sys_id);
rec.addQuery('state', 'IN_PROGRESS');
rec.query();
if(rec.next()){
rec.state = 'CANCELLED';
rec.update();
}
var inputs = {};
inputs['current'] = current;
inputs['table_name'] = current.getTableName();
// Execute the global flow called test_flow
sn_fd.FlowAPI.executeFlow('Flow Name Here', inputs);
})(current, previous);
Refer: Scripting with Flows, Subflows, and Actions
Regards
Ankur
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-13-2020 08:42 AM
@Ankur Bawiskar
Thanks , that fixed the cross-scope access issue. Now original flow gets cancelled but a new flow gets started, even after removing executeFlow block.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var rec = new GlideRecord('sys_flow_context');
rec.addQuery('name','Flow Name');
rec.addQuery('source_record', current.sys_id);
rec.addQuery('state', 'WAITING');
rec.query();
while(rec.next()){
rec.state = 'CANCELLED';
rec.update();
gs.info('--->flow state : '+ rec.state );
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2020 09:18 AM
Hi,
Please check the flow condition is Run once.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 07:43 AM
Hi Ankur,
One observation here is that flow gets executed again, However, approval won't trigger again if you have any prior approver. Any thoughts, please? Thanks.
Regards,
Nayan