How do I create a Problem Record whenever a P1 incident is created? I would like to copy fields from Incident to Problem Record.

Riya Singh
Kilo Contributor

I would like to copy below fields from Incident Record

  1. Short Description
  2. Description
  3. Assignment group
  4. Configuration Item
  5. Category
  6. Priority
  7. Impact 
  8. Urgency

 

Please help

1 ACCEPTED SOLUTION

Dhananjay Kulk1
Kilo Expert

Hi,

This is possible with Flow Designer but since you have asked via Business Rule, I will answer you that way.

Check below business rule "When to Run

find_real_file.png

 

Nothing in Actions Tab

 

In Advanced, you can check the below Script.

 

(function executeRule(current, previous /*null when async*/) {

//get sys id of problem managnment group
// var sys_id_of_group="";
// var assignment_grp_sys_id=new GlideRecord('sys_user_group');
// assignment_grp_sys_id.addQuery('name',"problem_managnment_group");
// assignment_grp_sys_id.query();
// if(assignment_grp_sys_id.next())
// {
// //if(assignment_grp_sys_id.getValue('name')=="problem_managnment_group")
// //{
// sys_id_of_group=assignment_grp_sys_id.sys_id;

// //}
// }

// get current record from incident table
var inc_short_description = current.short_description;
var description=current.description;
var assignment_group=current.getValue('assignment_group');
var current_number = current.number;
var current_config_item = current.getDisplayValue('cmdb_ci');
//inserting record into problem table
var problem_create=new GlideRecord('problem');
problem_create.initialize();
problem_create.short_description=inc_short_description;
problem_create.description=description;
problem_create.assignment_group=assignment_group;
problem_create.setDisplayValue('cmdb_ci',current_config_item);
problem_create.category = current.category;
problem_create.priority = current.priority;
problem_create.impact = current.impact;
problem_create.urgency = current.urgency;
var psys_id=problem_create.insert();
//newly created proble sys is set in problem id.
current.setDisplayValue('problem_id',psys_id);
current.update();
//if problem is created then notification send to incident assignment group.
if(current.problem_id)
{

if(current.assignment_group!=null)
{

//notification send when the problem has been created

gs.eventQueue('bc_inc_assign_group_send_noti',current,current.assignment_group.manager.email);
}
}


})(current, previous);

 

 

Thanks

Dhananjay Kulkarni

 

View solution in original post

3 REPLIES 3

Murthy Ch
Giga Sage

@Riya Singh

You can create using after insert business rule on incident table

where in the BR you can set the condition to run only when Priority is Critical.

and you can copy the values using current.field_name

 

Thanks,

Murthy

Thanks,
Murthy

MattiasJonsson
ServiceNow Employee
ServiceNow Employee

Agree, it can be done with BR. But, this is also where Flow Designer comes in handy.

It takes a minute to create there.

Make sure your trigger is set to run "once", so that it doesn't create new Problems each time an incident moves to P1 if it's deprioritized and then pushed up to P1 again - unless that's what you want of course.

find_real_file.png

 

If helpful or correct, please indicate so! 

Dhananjay Kulk1
Kilo Expert

Hi,

This is possible with Flow Designer but since you have asked via Business Rule, I will answer you that way.

Check below business rule "When to Run

find_real_file.png

 

Nothing in Actions Tab

 

In Advanced, you can check the below Script.

 

(function executeRule(current, previous /*null when async*/) {

//get sys id of problem managnment group
// var sys_id_of_group="";
// var assignment_grp_sys_id=new GlideRecord('sys_user_group');
// assignment_grp_sys_id.addQuery('name',"problem_managnment_group");
// assignment_grp_sys_id.query();
// if(assignment_grp_sys_id.next())
// {
// //if(assignment_grp_sys_id.getValue('name')=="problem_managnment_group")
// //{
// sys_id_of_group=assignment_grp_sys_id.sys_id;

// //}
// }

// get current record from incident table
var inc_short_description = current.short_description;
var description=current.description;
var assignment_group=current.getValue('assignment_group');
var current_number = current.number;
var current_config_item = current.getDisplayValue('cmdb_ci');
//inserting record into problem table
var problem_create=new GlideRecord('problem');
problem_create.initialize();
problem_create.short_description=inc_short_description;
problem_create.description=description;
problem_create.assignment_group=assignment_group;
problem_create.setDisplayValue('cmdb_ci',current_config_item);
problem_create.category = current.category;
problem_create.priority = current.priority;
problem_create.impact = current.impact;
problem_create.urgency = current.urgency;
var psys_id=problem_create.insert();
//newly created proble sys is set in problem id.
current.setDisplayValue('problem_id',psys_id);
current.update();
//if problem is created then notification send to incident assignment group.
if(current.problem_id)
{

if(current.assignment_group!=null)
{

//notification send when the problem has been created

gs.eventQueue('bc_inc_assign_group_send_noti',current,current.assignment_group.manager.email);
}
}


})(current, previous);

 

 

Thanks

Dhananjay Kulkarni