- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2024 12:00 AM
Hello, I have requirement in which is an RITM is created for a catalog item without records in particular tab in related list then that RITM state should be auto changed to 'Closed cancelled'.. Is there any way to achieve this .Thanks in advance any help is appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2024 12:29 AM
Hi @Sharath807 ,
You can try the below in after insert business rule:
var ritmRec = new GlideRecord('sc_req_item');
if (ritmRec.get(current.sys_id)) {
var checkReList = new GlideRecord('sc_task'); //Change with your table
checkReList.addQuery('request_item', ritmRec.sys_id); //update the field name here as per your table
checkReList.query();
if(!checkReList.next()){
ritmRec.setValue('stage', 'Request Cancelled');
ritmRec.setValue('state', 4);
ritmRec.update();
}
}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 01:19 AM
Hi @Sharath807 ,
Sure, try the below:
var ritmRec = new GlideRecord('sc_req_item');
if (ritmRec.get(current.sys_id)) {
var checkReList = new GlideRecord('sc_task'); //Change with your table
checkReList.addQuery('request_item', ritmRec.sys_id); //update the field name here as per your table
checkReList.query();
if (!checkReList.next()) {
ritmRec.setValue('stage', 'Request Cancelled');
ritmRec.setValue('state', 4);
ritmRec.update();
var reqUpdate = new GlideRecord('sc_request');
if (reqUpdate.get(ritmRec.request)) {
reqUpdate.setValue('approval', 'rejected'); //Set as per your requirement
reqUpdate.update();
}
}
}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 01:51 AM
@SN_Learn tried but the request is not updating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 02:16 AM - edited ‎08-04-2024 02:16 AM
Please share your code and screenshots of RITM and REQ
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 02:33 AM - edited ‎08-04-2024 02:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2024 02:42 AM
Hi @Sharath807 ,
Thanks for sharing the code, looks correct:
Could you please check adding the below line and try again:
var ritmRec = new GlideRecord('sc_req_item');
//RITM sysID
if (ritmRec.get(current.sys_id)) {
var checkReList = new GlideRecord('sc_task'); //Change with your table
checkReList.addQuery('request_item', ritmRec.sys_id); //update the field name here as per your table
checkReList.query();
if (!checkReList.next()) {
ritmRec.setValue('stage', 'Request Cancelled');
ritmRec.setValue('state', 4);
ritmRec.update();
var reqUpdate = new GlideRecord('sc_request');
if (reqUpdate.get(ritmRec.request)) {
reqUpdate.setValue('approval', 'rejected'); //Set as per your requirement
reqUpdate.setWorkflow(false);
reqUpdate.update();
}
}
}
Mark this as Helpful / Accept the Solution if this helps.