- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 04:31 AM - edited 09-04-2023 06:36 AM
**updated script below, had to change "closed_complete" to "3" for the sc_req_item (for sc_request it is not numeric). unfortunately it still does not work**
hello, i have created a BR for closing a REQ as soon as the RITM is closed. According to the BR Debugger, it is doing something but there is no outcome visible on the REQ status.
I would be interested if anyone can see where is the error. I will attach the BR i have created:
(function executeRule(current, previous) {
// first checking the RITM status
if (current.state == 'closed_complete') {
// then dot-walk to the REQ status
var parentRequest = new GlideRecord('sc_request');
if (parentRequest.get('number', current.request)) {
// Update the parent request's status to closed
parentRequest.request_state = 'closed_complete';
parentRequest.update();
}
}
}
)(current, previous);
**new script:**
(function executeRule(current, previous) {
// first checking the RITM status
if (current.state == '3') {
// then dot-walk to the REQ status
var parentRequest = new GlideRecord('sc_request');
if (parentRequest.get('number', current.request)) {
// Update the parent request's status to closed
parentRequest.request_state = 'closed_complete';
parentRequest.update();
}
}
}
)(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 06:43 AM - edited 09-04-2023 06:46 AM
Hi lmao,
Instead of 'number' you should use sys_id and current.state == '3'
(function executeRule(current, previous) {
// first checking the RITM status
if (current.state == '3') {
// then dot-walk to the REQ status
var parentRequest = new GlideRecord('sc_request');
if (parentRequest.get('sys_id', current.request)) {
// Update the parent request's status to closed
parentRequest.request_state = '3';
parentRequest.update();
}
}
}
)(current, previous);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 06:43 AM - edited 09-04-2023 06:46 AM
Hi lmao,
Instead of 'number' you should use sys_id and current.state == '3'
(function executeRule(current, previous) {
// first checking the RITM status
if (current.state == '3') {
// then dot-walk to the REQ status
var parentRequest = new GlideRecord('sc_request');
if (parentRequest.get('sys_id', current.request)) {
// Update the parent request's status to closed
parentRequest.request_state = '3';
parentRequest.update();
}
}
}
)(current, previous);
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 06:48 AM
thank you, it works now! 👍