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

Chuck Tomasi
Tera Patron

Hi David,



It could be that your new business rule is being overridden by data lookup rules. If priority is based on urgency & impact, and neither of those have changed, then changing the priority manually is not going to have an impact.



Check to see if this is a factor.



Data Lookup and Record Matching Support - ServiceNow Wiki


Hi Chuck,



Thanks for the advice but I don't think data lookup rules are blocking it as the Incident State Active on Assignment business rule works perfectly well for example see below.




Incident State Active on Assignment



When to run


Incident Sate is new or active


Assigned to is not empty



Actions


Incident State to Active


Priority to 1 - Critical



Test ticket created and assigned to a user



Raising status.PNG


Chuck Tomasi
Tera Patron

Well that rules that out. The only other way I can think is to check the Advanced checkbox and use the Condition field on the Advanced table instead of the condition builder.



Something like:



current.sys_created_on >= gs.hoursAgo(8) && current.active && current.priority == 2



Then your script becomes simple:



current.prioirty = 1;


Hi Chuck,



Thanks for the advise, I have to admit I'm not very skilled at JavaScript (Currently doing to code academy course)   but I believe I've placed it all in correctly. All I can do now is wait 8 hours and hope for the best!  



Here are some screenshots of the business rule, if you see anything wrong just let me know.



Top Part of Rule


Raising status3.PNG



Code Part




Raising status2.PNG