Set Value from Background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 03:44 AM
How to set priority value to 1 from background script on the incident shown below.
i need the query to set the priority value to 1 and assignment value also to "Database".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:07 AM
Priority is calculated from impact and urgency, so depending on those two values (check your priority lookup to see the combinations that make it a P1, and select the one that applies). Update impact and urgency through the script. Setting priority directly will only get it reverted when the data lookup checks on impact and urgency again. Not sure why people are suggesting that.
VaishnaviShinde looks to be the only one providing you with the correct script.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:15 AM
HI @shid077
Try below script:
var grInc = new GlideRecord("incident");
grInc.addQuery("number", "INC0009009");
grInc.query();
if(grInc.next()){
grInc.impact = 1;
grInc.urgency = 1;
grInc.assignment_group = "<sys_idofhardware group>";
grInc.update();
}
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:24 AM
You can run below script :
var incidentID = 'your_incident_sys_id'; // replace with the actual Sys ID of the incident you want to update
var incident = new GlideRecord('incident');
if (incident.get(incidentID)) {
incident.priority = 1;
incident.assignment_group.setDisplayValue('Database'); // Assuming 'Database' is the display value of the assignment group
incident.update();
gs.info('Incident updated successfully: ' + incident.number);
} else {
gs.error('Incident not found with Sys ID: ' + incidentID);
}
Kindly mark helpful/accepted if it helps you.
Thanks