- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 01:48 PM
Hello Genius,
I have a small requirement, If RITM state is set to closed incomplete, the relevant request should get closed incomplete. Due to workflow it is not updating it properly. Can any one help me on this please.
Kindly note, when the RITM is set to Closed Incomplete, we have to set RITM stage as closed incomplete & RITM Approval as "Rejected" and REQ Request state as "Closed Incomplete" & REQ Approval as "Rejected". I have tried few ways but no luck.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 03:11 PM
Hi Arun,
I have tried below Business rule on after insert/update on sc_req_item and it's working, please try and see if it helps.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var req_item = new GlideRecord('sc_req_item');
req_item.get(current.sys_id);
if(req_item.state =='4')
{//Set your appropriate state here
req_item.stage ='Closed Incomplete';
req_item.approval = 'Rejected';
req_item.update();
var req = new GlideRecord('sc_request');
req.get(req_item.getValue('request'));
req.request_state = 'Closed Incomplete';
req.approval = 'Rejected';
req.update();
}
})(current, previous);
BR Configuration:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 02:08 PM
hi arun,
you can refer below code as reference and modify as per your requirements.
match ritm states to closed task states
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 02:10 PM
You should be able to achieve this with a set values utility on the workflow. Or, if you want to do it across the board (and not just individual workflows) then do an after business rule on the ritm...after ritm state changes to closed complete query for the related request and set its state.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 02:11 PM
I believe you can achieve this by having the After Insert/update Business Rule on RITM table with the condition when RITM stage as closed incomplete.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2017 03:11 PM
Hi Arun,
I have tried below Business rule on after insert/update on sc_req_item and it's working, please try and see if it helps.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var req_item = new GlideRecord('sc_req_item');
req_item.get(current.sys_id);
if(req_item.state =='4')
{//Set your appropriate state here
req_item.stage ='Closed Incomplete';
req_item.approval = 'Rejected';
req_item.update();
var req = new GlideRecord('sc_request');
req.get(req_item.getValue('request'));
req.request_state = 'Closed Incomplete';
req.approval = 'Rejected';
req.update();
}
})(current, previous);
BR Configuration: