Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Automatically generate a problem from priority 1 incident

cjhampton
Kilo Explorer

All,

I need to generate a Problem Record when an incident is classified as a priority 1.   I've tried using a client script to call the oob create problem ui action, but I would like this to happen in the background.   Anybody have a script that does this?

1 ACCEPTED SOLUTION

You are welcome.



Kindly mark answer as correct / helpful if it solves your problem


View solution in original post

19 REPLIES 19

saritha9
Giga Expert

Create a Business Rule After Insert/Update



GlideRecord - ServiceNow Wiki


Deepak Ingale1
Mega Sage

Hi,


Create After Insert business rule



condition : current.priority   == 1;



var gr = new GlideRecord('problem');


gr.initialize();


gr.short_description = current.short_description;


// you can set other fields also based on above code or can refere to create problem UI action code as well


if(gr.parent.nil())


{


gr.insert();


}



Do it in some demo instance or sandbox and check completely.


You can add modified code as follow



After insert / update business rule



condition :



current.incident_state != 7 && current.problem_id.nil() && current.priority == 1




var prob = new GlideRecord("problem");
prob.short_description = current.short_description;
prob.cmdb_ci = current.cmdb_ci;
prob.priority = current.priority;
prob.company = current.company;
prob.sys_domain = current.sys_domain;
var sysID = prob.insert();


current.problem_id = sysID;
var mySysID = current.update();


gs.addInfoMessage("Problem " + prob.number + " created");
action.setRedirectURL(prob);
action.setReturnURL(current);


Thanks for the info!



One minor adjustment that we needed to make was to have the PRB created when:



The incident was Inserted and Updated and the priority was updated and the priority is 1 - critical.



We needed to do this because when we closed the PRB, it would update the associated Inc, which would then spawn another PRB.