check the triggered task status - closed complete then return complete else request cancelled
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:36 PM
Hi All, having a requirement that at the end of the workflow if all the triggered tasks are closed completed then update RITM as closed complete
else if any one of the task is closed incomplete or closed skipped then need to update the RITM as closed incomplete and request rejected.
Any suggestions.
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:58 PM
Hi @Community Alums,
Try this:
var taskRecords = new GlideRecord('sc_task');
taskRecords.addQuery('request_item', current.sys_id);
taskRecords.addQuery('state','IN','4,7');
taskRecords.setLimit(1);
taskRecords.query();
if (taskRecord.hasNext()){
current.state = '4';
var request = current.request.getRefRecord();
if (request.isValidRecord()){
request.approval = 'rejected';
request.update();
}
}
else{
current.state = '3';
}
current.update();
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.