Cancel Approval record and Restart Flow designer Flow
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Please help me with Business rule in order to implement if Expense record is modified before Approval or Rejection, the existing record in Approval table must be set with State-> No longer Required and then my Flow Designer flow must restart. Currently this is my Business Rule script:-
(function executeRule(current, previous /*null when async*/) {
// 1. Cancel existing approvals
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval', current.sys_id);
while (approvalGR.next()) {
approvalGR.state = 'not_required';
approvalGR.update();
}
// 2. Restart Flow Designer flow
if (current.flow_context) {
try {
sn_fd.FlowAPI.restartFlow(current.flow_context);
gs.info('Flow restarted for record: ' + current.number);
} catch (e) {
gs.error('Error restarting flow: ' + e);
}
} else {
gs.warn('No active flow context found for record: ' + current.number);
}
})(current, previous);
This is an After Update BR with conditions:- when 'Updates' changes and 'Approval Status' is 'Requested'.
0 REPLIES 0