- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2020 01:35 PM
Can flow designer detect a change in field value for the purposes of restarting the entire flow? We have a requirement that any time the Due Date value changes on our record, the flow should restart so that it can re-evaluate which state it should be in based on a script. I currently have the Flow designed to trigger any time a record is created or updated, and the Due Date changes and isn't empty. My fear is that the Flow will create a new instance of Flow each time the record is updated, without cancelling the old flow.
Solved! Go to Solution.
- Labels:
-
flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 05:41 PM
hi
One approach is to have your main flow to trigger 'Only if not currently running'.
Then have a before business rule to trigger when the 'Due Date' changes. The BR script will cancel the existing workflow(s).
Your main workflow will then trigger again as it is not currently running:
example:
before business rule calls a flow designer action on Due Date change (code grabbed from flow designer code snippet):
(function executeRule(current, previous /*null when async*/ ) {
try {
var inputs = {};
inputs['sourcerecord'] = current; // String
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
var result = sn_fd.FlowAPI.getRunner().action('global.cancel_flow').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Current action has no outputs defined.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})(current, previous);
Flow designer action looks up records on the sys_flow_context table that matches incident record:
For each record run the script to cancel:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2020 07:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 05:41 PM
hi
One approach is to have your main flow to trigger 'Only if not currently running'.
Then have a before business rule to trigger when the 'Due Date' changes. The BR script will cancel the existing workflow(s).
Your main workflow will then trigger again as it is not currently running:
example:
before business rule calls a flow designer action on Due Date change (code grabbed from flow designer code snippet):
(function executeRule(current, previous /*null when async*/ ) {
try {
var inputs = {};
inputs['sourcerecord'] = current; // String
// Start Asynchronously: Uncomment to run in background. Code snippet will not have access to outputs.
var result = sn_fd.FlowAPI.getRunner().action('global.cancel_flow').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Current action has no outputs defined.
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
})(current, previous);
Flow designer action looks up records on the sys_flow_context table that matches incident record:
For each record run the script to cancel:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2020 03:11 PM
Any other ideas on this? I don't want to cancel my whole flow just to check if a field changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2020 04:09 PM
Hi
I would suggest posting a new question to the community with more details of your requirement.
The original poster of this question specifically wanted their flow to restart on the field change.