
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:06 AM - edited 11-28-2022 12:13 AM
Hi All,
I have written below code in run script activity of workflow to check state of tasks and accordingly set state of RITM, but it's not working. Please do suggest where I am lacking.
Workflow -
Script -
var cc = 0;
var ci = 0;
var cs = 0;
var other = 0;
var rec = new GlideRecord('sc_task');
rec.addQuery('request_item', current.sys_id);
rec.query();
while (rec.next()) {
if (rec.getValue('state') == 3) {
cc++;
} else if (rec.getValue('state') == 4) {
ci++;
} else if (rec.getValue('state') == 7) {
cs++;
} else {
other++;
}
}
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.getValue('request_item'))) {
if (ci > 0) {
ritm.setValue('state', 4);
} else if (cs > 0 && cc == 0 && ci == 0) {
ritm.setValue('state', 7);
} else if (cc > 0 && cs == 0 && ci == 0) {
ritm.setValue('state', 3);
} else {
gs.info('Some other combination of closed happened, not setting RITM state');
gs.info('Closed other count: ' + other);
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:10 AM
Hi @Community Alums
You don't need the 2nd glide record for the RITM, since you are already running the WF on the RITM table
You can just use, current to update value of the states, no need to use gliderecord here.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:10 AM
Hi @Community Alums
You don't need the 2nd glide record for the RITM, since you are already running the WF on the RITM table
You can just use, current to update value of the states, no need to use gliderecord here.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:46 AM
Thanks @Aman Kumar S it worked.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 01:04 AM
Awesome!
Glad it worked out
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 12:29 AM