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

This is great, thank you for the support


Hi Chuck,



I have been testing the code above in a service now dev environment along with our own dev environment but it doesn't seem to work.



I've tried executing the script along with applying run times but the P2s don't seem to change at all. Can you advise?



Raising status5.PNG


Hi David,



Before I run anything in a scheduled job, I always test in scripts background. Have you tested there?



Also, if you add the line:



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



right after the "inc.query();" line, it will output how many records it plans to update. That should help diagnose any potential issues. Comment that out in your scheduled job before it goes in to production however.


Hi Chuck,



Its very odd, the background script shows no records are found. There are P2's in the system (I've double checked that)



Hayley Dodd1234.PNG



I've been comparing this code I've found online such as in Change Urgency to High if User is VIP - ServiceNow Wiki     Would this code not need to call some sort of IF statement to check the fields?


The database is doing the field checking with the various query lines. I'll try to take a look at it in a bit.