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.

Auto Problem Record Creation from Incident

Service Now21
Kilo Contributor

Once the major incident is closed , I want to create Problem Record from there automatically.

 

How to achieve that ?

2 REPLIES 2

saiiaskumar
Giga Guru

Create After Business Rule on Incident Table

When : After

Update : True

Condition : State changes to completed

var newProblemID;
var gr = new GlideRecord("problem");
gr.initialize();
gr.short_description = current.short_description;
gr.description = current.description;
gr.category = current.category;
gr.subcategory = current.subcategory;
gr.assignment_group = current.assignment_group;
gr.business_service = current.business_service;
gr.cmdb_ci = current.cmdb_ci;
gr.comments = gs.getMessage("This is created after completing of incident - {0}",current.number);
newProblemID = gr.insert();
current.problem_id = newProblemID;
current.comments = gs.getMessage("New Problem - {0} is created for this incident",gr.number);
current.update();
gs.addInfoMessage(gs.getMessage("New Problem - {0} is created for Incident - {1} ",[gr.number,current.number]));

Hello Sai,

Your code looks fine. I just wanted to add few points here:

1.Use of current.setWorkflow(false); as you have used current.update() in after business rule.

2. Or we can gliderecord table and can update using gr.update();

3. It it not recommended to use current.update() in After Business Rule.

 

 

Thanks,

Abhishek

 

 

Thank you,
Abhishek Gardade