Create a problem Record when incident ticket is created in Business Rules

Sai Mithra Siri
Kilo Contributor

In Business rules

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Sai Mithra Siripuram ,

This is done with a UI action called "Create Problem". It is available from the form menu (or right-click on the form header.) You can find the definition for this UI action in your instance here:

https://YOURINSTANCE.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=2f43c471c0a8006400a07440e...

If you are looking at a BR, then below script in before BR on incident table:

- Configuration item
- Priority
- Assignment group
- Short Description
- Description



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

        var newPRB = new GlideRecord('problem');
   
        newPRB.cmdb_ci = current.cmdb_ci;
        newPRB.location = current.location;
        newPRB.short_description = 'PRB raised' + current.number + ' - Auto Generated';
        newPRB.description = 'PRB raised  ' + current.number + '\nIncident description: ' + current.description;
        newPRB.assignment_group = current.assignment_group; 
        newPRB.insert();

current.problem_id = newPRB.sys_id;

})(current, previous);

 

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

Hi @Sai Mithra Siripuram ,

This is done with a UI action called "Create Problem". It is available from the form menu (or right-click on the form header.) You can find the definition for this UI action in your instance here:

https://YOURINSTANCE.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=2f43c471c0a8006400a07440e...

If you are looking at a BR, then below script in before BR on incident table:

- Configuration item
- Priority
- Assignment group
- Short Description
- Description



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

        var newPRB = new GlideRecord('problem');
   
        newPRB.cmdb_ci = current.cmdb_ci;
        newPRB.location = current.location;
        newPRB.short_description = 'PRB raised' + current.number + ' - Auto Generated';
        newPRB.description = 'PRB raised  ' + current.number + '\nIncident description: ' + current.description;
        newPRB.assignment_group = current.assignment_group; 
        newPRB.insert();

current.problem_id = newPRB.sys_id;

})(current, previous);

 

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Community Alums
Not applicable

Hi @Sai Mithra Siripuram ,

Kindly mark the applicable answer as Correct & Helpful both such that others can get help.

Thanks,
Sandeep

Snehangshu Sark
Mega Guru

Hi Sai,

 

Please use the BR and do the field mapping before you apply it. In the BR, set the Table as "Incident".

In the field mapping, prb contains the problem ticket that is going to be created and current is the incident table.

 

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

    var prb = new GlideRecord('problem');
	prb.initialize();
    prb.<fieldName> = current.<fieldName>;  // do the field mapping
	.  
	.
	.
	.
    
    prb.insert();

})(current, previous);

 

Regards,

Snehangshu Sarkar

 

Please mark an appropriate response as correct if my answer replied to your question.

pratiksha5
Mega Sage

user after business rule on incident table, mark it after insert. 

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

var gr = new GlideRecord("problem");
gr.initialize();
gr.short_description = current.short_description;
gr.first_reported_by_task = current.sys_id;
gr.assingment_group = current.assingment_group;
gr.description = "this is a problem record created by an incident";
gr.cmdb_ci = current.cmdb_ci;
gr.insert();

})(current, previous);