- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 11:07 AM
There is a list of incidents which are in Closed state. We are in a situation to change the assignment group of all those incidents without changing any group. But right now when we try to change the group for those closed incidents, the state is also changed to "New" state.
What is the approach we have to follow in order to change only the assignment group of closed incidents without changing any other fields?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 12:16 AM
@Black Coder There must be some custom business rule or client script which is changing status of incident record to New state. But we are using "grIncident.setWorkflow(false)" in our script which will prevent execution of any business rule or client script.
To replicate this issue, I created custom business rule which is changing the status of incident record from "Closed" to "New" when assignment group changes
I ran below code without setWorkflow(false), then it changed state of incident to New because business rule got executed
var grIncident = new GlideRecord('incident');
if (grIncident.get('470af5afa9fe198101b324dd773ef379')) //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.update();
}
I ran below code with setWorkflow(false), then it does not changed state of incident to New because business rule didn't executed
var grIncident = new GlideRecord('incident');
if (grIncident.get('e329de99731423002728660c4cf6a73c')) //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}
Could you please share screenshot of script which you are executing
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 11:48 AM
@Black Coder You can use background script to achieve this.
Run below query for multiple records
var grIncident = new GlideRecord('incident');
grIncident.addEncodedQuery('numberININC0000050,INC0009004,INC0000601^state=7'); // create encoded query from incident list view and put it here
grIncident.query();
while (grIncident.next()){
grIncident.setValue('assignment_group', '8a5055c9c61122780043563ef53438e3', 'Hardware'); //put the sys id and display value of assignment which you want to update
grIncident.setWorkflow(false);
grIncident.update();
}
Run below query for single record to test
var grIncident = new GlideRecord('incident');
if (grIncident.get('ef43c6d40a0a0b5700c77f9bf387afe3')) //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2023 05:22 PM
I tried with above script you have shared. The issue is when I ran this script to change the group, it changed the state of an incident from Closed to a New state too.
Here I should not update the state and have to keep as Closed state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 12:16 AM
@Black Coder There must be some custom business rule or client script which is changing status of incident record to New state. But we are using "grIncident.setWorkflow(false)" in our script which will prevent execution of any business rule or client script.
To replicate this issue, I created custom business rule which is changing the status of incident record from "Closed" to "New" when assignment group changes
I ran below code without setWorkflow(false), then it changed state of incident to New because business rule got executed
var grIncident = new GlideRecord('incident');
if (grIncident.get('470af5afa9fe198101b324dd773ef379')) //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.update();
}
I ran below code with setWorkflow(false), then it does not changed state of incident to New because business rule didn't executed
var grIncident = new GlideRecord('incident');
if (grIncident.get('e329de99731423002728660c4cf6a73c')) //incident sys_id
{
grIncident.setValue('assignment_group', '8a4dde73c6112278017a6a4baf547aa7', 'Software');
grIncident.setWorkflow(false);
grIncident.update();
}
Could you please share screenshot of script which you are executing
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 12:25 AM
Thanks It resolved my issue @SANDEEP28