How to set Problem Priority based on Incident Priority (in Business Rule)

jas101
Tera Expert

Hello everyone.

We have a business rule that creates a problem record automatically when a major incident record is resolved. Currently the business rule looks something like this:

var prob = new GlideRecord("problem");

prob.u_mi_reference = current.sys_id;

prob.short_description = current.short_description;

prob.description = current.description;

prob.cmdb_ci = current.cmdb_ci;

prob.u_category = current.category;

prob.priority = current.priority;

prob.u_source = 2;

However we are overhauling our Problem priorities so they will now be distinct from Incident priorities. Subsequently please can someone help tell me how I can set the new Problem priority based on the Incident one given that they are no longer matching? E.g. we will want the Problem record priority to be 'P1 - Critical' if the Incident has a priority of 'MI - P1' or 'MI - P2' or if the Incident is priority 'MI - P3' or 'MI - P4' then the Problem priority needs to be 'P2 - High'.

Many thanks in advance for any assistance.

Daniel

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

You can define an array that will hold the mapping of incident to problem priority mapping.



Ex



var problemPriority = [];


problemPriority[1]=1;


problemPriority[2]=1;


problemPriority[3]=2;


problemPriority[4]=2;



prob.priority = problemPriority[current.priority];



Note : Change the values as per your need.


View solution in original post

10 REPLIES 10

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

What about changing this part in your script:



prob.priority = current.priority;


to something like this:



if (current.priority == 1 || current.priority == 2 ){


      prob.priority = 1;


}


else if (current.priority == 3 || current.priority == 4 ){


    prob.priority = 2;


}


Regards,


Sergiu


Hi I also tried setting incident priority based on priority of Application CI in below script-


var glide = new GlideRecord('cmdb_ci_app_server');


glide.addQuery('name','Servicenow');


glide.query();


if(glide.hasNext()){


var pri= glide.u_priority;


if(pri == 'critical'){


  current.impact=1;


  current.urgency=1;


}


else


  current.impact=2;


  current.urgency=2;


}



But "pri" is receiving value "undefined". Please comment on this ASAP.


sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Is field "u_priority" present on table "cmdb_ci_app_server" ?


I have created a new field 'u_priority'   a choice field on cmdb_ci_app_server and given choices-critical, high, medium and low.