How to raise priority using a business rule

davidwood
Kilo Contributor

Hi All,

I'm new to world of service now and was looking for assistance on a business rule.

I'd like to make is to a priority 2 incident is raised to priority 1 eight hours after being raised/opened as a p2.       I've tried many different tests within business rules but nothing seems to work (We are on Fuji)

When to run

When: Before

Order: 100

Filter Conditions

Active is true

Priority is 2 - High

Duration is   Days 0   Hours 8

Actions

Urgency to 1 - High

Impact to 1 - High

Priority to 1 - Critical

The closest out of the box business rule is Incident State Active on Assignment which I've been playing around with a bit as well.   Can someone offer some advice?

1 ACCEPTED SOLUTION

Change of approach. I built the list filter to get it the way I wanted, then copied the query and used it in the addEncodedQuery() method like this.



var inc = new GlideRecord('incident');  


inc.addEncodedQuery('active=true^priority=2^sys_created_on<javascript:gs.hoursAgoStart(8)');  


inc.query();  


gs.log(inc.getRowCount() + ' records found');



while (inc.next()) {  


  inc.priority = 1;  


  inc.update();


}  


I did not update your scheduled job or records.


View solution in original post

19 REPLIES 19

Hi David,



It looks like the INSERT and UPDATE buttons need to be checked or this rule will never get triggered.



Once you do that, it will only update the priority if another update is also made and it meets those conditions. It's not going to update automatically. So it your incoming ticket sits for 10 days, the priority will still be 2.



You might be more interested in a scheduled job to run periodically based on time, not someone making another update. (I sort of feel like a car salesman upselling you on ServiceNow functionality now.)


Hi Chuck,



Yes this is looking more like it! Scheduled jobs seem to be the way to go but they're even more scripting heavy.



How does this look?   (I've done it for 1 hours just to test)



Raising status4.PNG


Unfortunately, current isn't know to scheduled jobs. I'll build you something shortly. Just so I understand the requirements:



  • Look through all active P2 incidents.
  • If the data created is > 8 hours ago, upgrade it to P1

Is that it?


Hi Chuck,



That would be amazing, thanks for the help.



- Look through all active P2 incidents


- If the incident has been a P2 for more than 8 hours raise to P1


- (So if the ticket was a p3 for a while and then becomes a p2 the timer only starts when the tickets a p2)


Here you go:



Adjust the periodicity as needed:



find_real_file.png



Here's the script so you don't have to retype, just copy/paste:



var inc = new GlideRecord('incident');


inc.addActiveQuery();


inc.addQuery('priority', 2);


inc.addQuery('sys_created_on', '>=', gs.hoursAgo(8));


inc.query();



while (inc.next()) {


  inc.priority = 1;


  inc.update();


}



And most importantly, TEST TEST TEST in pre-production. 🙂