- 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 05:13 AM
Check your sys_choice records for table=sc_req_item and element=state as the values are numerical.
Try updating...
if (current.state == 'closed_complete') {
to
if (current.state == '3') {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 06:27 AM
thank you for the help, it was indeed incorrect. i have set it to '3' now but it still doesnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 05:30 AM
hi, @lmao seems that you haven't used the backend value of "closed_complete" i.e. '3'
use current.state=='3'
Hope this answer helps, give it a thumbs up if it works!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 06:26 AM
Hello @Mudit_Singh indeed the value is numeric and i set it to '3' now but unfortunately still no outcome...