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 Ctomasi.



Any luck with investigating that code?



I've tried swapping Priority to Urgency and other items but the same "0 tables found" result display's.       I'm doing this all on a service now developer environment so I could possibly give you access to it if you like.


Sorry, I've been consumed with Knowledge16 for the past couple weeks. I've just requested to follow you. If you follow me back we can exchange credential information to that instance and I can take a look.



Thanks.


Hi Chuck,



No worries at all!   I'll send you over the details shorly, thanks for the help again.


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.


Hi Chuck,



Yes! its working! its really working!! Had to tweek the code a little bit more in the end. For some reason you can override proirty in a business rule but in a script it appears urgency and impact have to be raised instead.




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.urgency = 1;  


          inc.impact = 1;    


  inc.update();    
}