- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:19 PM - edited 05-22-2024 11:23 PM
I am trying to bulk update incident priority via a background script. To update the priority in my instance, I need to set the impact and urgency. When I update the records via the background script below, I get some errors,which I can't figure out. But at the same time the ticket priority gets updated to Priority 4.
////Change the priority of active incident
var gr = new GlideRecord('incident');
gr.setLimit(5); //limit only first 2 record
gr.addQuery('type', 'incident');
gr.addQuery('active', true);
gr.addQuery('priority', '3');
gr.addQuery('u_urgent_p3',false);
gr.query();
gs.print(gr.getRowCount());//Count the record numbers
while(gr.next())
{
//shift the priority from P3==>P4
gr.impact = 3; // Set impact to 3 - Low
gr.urgency = 2; // Set urgency to 2 - Medium
//gr.work_notes = 'The priority of this ticket has been adjusted (P3 -> P4)';
//gr.setValue('impact', '3'); // Set impact to 3 - Low
//gr.setValue('urgency', '2'); // Set urgency to 2 - Medium
gr.setWorkFlow(false);//stop firing BR
gr.update();
gs.print(gr.number + ', Priority: ' + gr.priority);//Print the record number
}
Error eg:-
*** Script: 5
Invalid query string received:4,-30,-40,3,-10,6: null
Invalid query string received:4: null
Invalid query string received:Incident: null
Invalid query string received:7: null
Slow business rule 'Run SLAs' on incident:<span class = "session-log-bold-text"> INC0087611</span>, time was: 0:00:00.417
*** Script: INC0087611, Priority: 4
Invalid query string received:4,-30,-40,3,-10,6: null
Invalid query string received:4: null
Invalid query string received:Incident: null
Invalid query string received:7: null
Slow business rule 'Run SLAs' on incident:<span class = "session-log-bold-text"> INC0089362</span>, time was: 0:00:00.496
*** Script: INC0089362, Priority: 4
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:28 PM
The problem is the type with disabling Workflows, therefore they are still running in the background causing some error messages.
Instead write (with a lower "f")
gr.setWorkflow(false)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 11:32 PM
Looks like , instead of setWorkflow(false) you are using setWorkFlow(false) which is causing the issue due to incorrect syntax.
gr.setWorkFlow(false);//stop firing BR
Correct:
gr.setWorkflow(false);//stop firing BR
Please mark my answer as correct and helpful based on Impact.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 01:05 AM
After played around a bit and I noticed that i wanted that BR to be run while updating the incidents through background script. So, I have commented out that //gr.setWorkflow(false);
I am still getting that below error:
Background script:
////Change the priority of active incident
var gr = new GlideRecord('incident');
gr.setLimit(5); //limit only first 2 record
gr.addQuery('type', 'incident');
gr.addQuery('active', true);
gr.addQuery('priority', '3');
gr.addQuery('u_urgent_p3',false);
gr.query();
gs.print(gr.getRowCount());//Count the record numbers
while(gr.next())
{
//shift the priority from P3==>P4
gr.impact = 3; // Set impact to 3 - Low
gr.urgency = 2; // Set urgency to 2 - Medium
//gr.work_notes = 'The priority of this ticket has been adjusted (P3 -> P4)';
//gr.setValue('impact', '3'); // Set impact to 3 - Low
//gr.setValue('urgency', '2'); // Set urgency to 2 - Medium
//gr.setWorkflow(false);//stop firing BR
gr.update();
gs.print(gr.number + ', Priority: ' + gr.priority);//Print the record number
}
Error:
*** Script: 5
Invalid query string received:4,-30,-40,3,-10,6: null
Invalid query string received:4: null
Invalid query string received:Incident: null
Invalid query string received:7: null
Slow business rule 'Run SLAs' on incident:<span class = "session-log-bold-text"> INC0105374</span>, time was: 0:00:00.398
*** Script: INC0105374, Priority: 4
Invalid query string received:4,-30,-40,3,-10,6: null
Invalid query string received:4: null
Invalid query string received:Incident: null
Invalid query string received:7: null
Slow business rule 'Run SLAs' on incident:<span class = "session-log-bold-text"> INC0105554</span>, time was: 0:00:00.481
*** Script: INC0105554, Priority: 4
Invalid query string received:4,-30,-40,3,-10,6: null
Invalid query string received:4: null
Invalid query string received:Incident: null
Invalid query string received:7: null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 01:21 AM
Hi @attanhes ,
Please try the below:
var gr = new GlideRecord('incident');
gr.addQuery('type', 'incident');
gr.addQuery('active', true);
gr.addQuery('priority', '3');
gr.addQuery('u_urgent_p3',false);
//You can replace all the above addQuery with one encoded query(addEncodedQuery)
gr.setLimit(5); //limit only first 2 record
gr.query();
gs.print(gr.getRowCount());//Count the record numbers
while(gr.next())
{
//shift the priority from P3==>P4
gr.impact = 3; // Set impact to 3 - Low
gr.urgency = 2; // Set urgency to 2 - Medium
//gr.work_notes = 'The priority of this ticket has been adjusted (P3 -> P4)';
//gr.setValue('impact', '3'); // Set impact to 3 - Low
//gr.setValue('urgency', '2'); // Set urgency to 2 - Medium
//gr.setWorkflow(false);//stop firing BR
gr.update();
gs.print(gr.number + ', Priority: ' + gr.priority);//Print the record number
}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2024 01:36 AM
Sorry, still no luck.
I am getting same error.