Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Set Incident 'Priority' based on 'Business Criticality' of a 'Service'

WazzaJC
Tera Expert

Set Incident Priority based on Business Criticality of a Service

 

Hi Guys, I'd really appreciate any help/guidance on an appropriate Script or Business Rule to use, to achieve the following:

My client has a requirement that the 'Priority' is auto-populated, based on the 'Business Criticality' that is associated to the 'Service' (cmdb_ci_service) that is selected by the User, all configured on the standard 'Incident' Form, on the 'Incident' Table.

 

Example, if the 'Business Criticality' associated with the 'Service' selected = '1 - most critical' then set the 'Priority' of the Incident to '1 - Critical'. etc

Example, if the 'Business Criticality' associated with the 'Service' selected = '3 - less critical' then set the 'Priority' of the Incident to '3 - moderate'. etc

 

How can I achieve this via Client Script or Business Rule and what would be an example of the Script or Business Rule details I need to achieve this please ?

 

Many thanks - any help greatly appreciated as always.

1 ACCEPTED SOLUTION

Sid_Takali
Kilo Patron

Hi @WazzaJC  try onChange client script 

function onChange(control, oldValue, newValue, isLoading) {
     var caller = g_form.getReference('ReferenceFieldName', doAlert); // doAlert is our callback function
}

function doAlert(service) { //reference is passed into callback as first arguments
   if (service.business_critically == '1')
     {
   g_form.setValue('priority','1');
}
else if (service.business_critically == '2')
     {
   g_form.setValue('priority','2');
}
else {
g_form.setValue('priority','3');
}
}

View solution in original post

5 REPLIES 5

Samaksh Wani
Giga Sage

 

var service = g_form.getValue("service");
if(service == "1"){
g_form.setValue('priority', "1");
}

 

 

You need to write this in OnChange() Client Script.

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Samaksh

Hi Samaksh,

I don't believe this correctly addresses my query - have you tried this on your PDI and it works? It does not work for me.

I am talking about Business Criticality associated with a Service which is then used to set the Priority, as per the details in my note.

Many thanks.

@WazzaJC 

 

What will be the common field between both table 

Sid_Takali
Kilo Patron

Hi @WazzaJC  try onChange client script 

function onChange(control, oldValue, newValue, isLoading) {
     var caller = g_form.getReference('ReferenceFieldName', doAlert); // doAlert is our callback function
}

function doAlert(service) { //reference is passed into callback as first arguments
   if (service.business_critically == '1')
     {
   g_form.setValue('priority','1');
}
else if (service.business_critically == '2')
     {
   g_form.setValue('priority','2');
}
else {
g_form.setValue('priority','3');
}
}