- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 05:37 AM
Hi I have created a BR on request table, where it checks whether its parent is empty or not.
if not empty then it glide incident table and check for the concerned parent incident and sets it state to request created.
upto this is fine, but I want to set the incident active to false along with its state.
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent);
gr.query();
if(gr.next()){
gr.state = '9';
gr.active = false;
gr.work_notes='Incident converted to request \n Kindly access Request from Related List';
gr.update();
}
this is changing the state but not setting the active to false.
what to do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 09:47 AM - edited ‎05-24-2023 09:51 AM
When I tested this and got it to work, I did the condition on the first tab..."when to run" via the GUI, not on the advanced tab. The advanced tab condition is still "current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.CANCELED"
^^ I already deleted the custom state in my PDI before I took this screener, but I did this with a custom state of "Request created"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 08:23 AM
Did you try in BG scripts or modifying your BR and running on demand? Also @Steven Parker solution should totally work, but for the modified condition on the BR to work, do make sure you are putting the name of the custom state you created (value = 9) in ALL_CAPS_WITH_UNDERSCORES_NOT_SPACES -- not always obvious, IMO
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 08:56 AM
yes I tried in my BG and also updated my BR. i am seeing no error and even when I run the BG script i can see this
but the incident is not updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 09:17 AM
I tested this against the sc_task table and your script works...further, it triggers an oob BR which changes the state of the TASK also.
I have the same results against incident, as you're experiencing...so, I would definitely say this has to do with a BR looking @ incident state and setting it to "active" because it isn't "closed" or "cancelled".
I did a bit of digging on my PDI and found a BR called "incident reopen", which is doing a before update action, where 'active = false' and has the conditions @Steven Parker mentions here. I added the condition for "State does not equal <custom state>" and it seems to work, but also wants a close code and resolution note...so as long as you satisfy those conditions, this should work. I'd recommend modifying both the "incident reopen" and "mark closed" ones.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 09:21 AM - edited ‎05-24-2023 09:22 AM
FYI, I tested it and this works in BG scripts after adjusting the "incident reopen" BR that I described above.
var gr = new GlideRecord('incident');
gr.addQuery('number','INC0010001');
gr.query();
if(gr.next()){
gr.active = 'false';
gr.state = '9';
gr.close_code = 'No resolution provided';
gr.close_notes = 'test';
gr.update();
}
Note - this works with or without quotes on "gr.active = false"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 09:30 AM
made change in incident re open and tried your script as well but not working