Whenever Priority 1 incident is open then Problem Ticket should be genetrated automatically. How can i achieve this through Business rule.?

Prabhat4
Tera Contributor

Hi guys,

I'm trying to create problem ticket through P1 INC generation. i want to achieve this by using business rule. Please advise how can i achieve this, response in beginning to end is much appreciated.

Thanks

Prabhat

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi Prabhat,



as deepak.ingale has already suggested with after business rule that will work perfectly.


i am just adding few points here.


if you will create problem from incident then in problem form there is a related list "Incident" when ever some Problem get created from that incident will attached there.


so here you go try with script below. i tested and it's working perfectly.



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



// Add your code here


var CreateProb = new GlideRecord('problem');


CreateProb.short_description = current.short_description;


CreateProb.cmdb_ci = current.cmdb_ci;


CreateProb.impact = current.impact;


CreateProb.urgency = current.urgency;


CreateProb.priority = current.priority;


CreateProb.company = current.company;


var sysID = CreateProb.insert();


current.problem_id = sysID;


current.setWorkflow(false);


var mySysID = current.update();



gs.addInfoMessage("Problem " + CreateProb.number + " created");


})(current, previous);




I used condition in business rule "When to run" tab.



find_real_file.png



To show the message either you use "Action" tab or gs.addInformMessage() function in script. so i used both of them.



find_real_file.png



incidents.png



Final Result



incidents.png


Hope it will help you.


View solution in original post

8 REPLIES 8

Deepak Ingale1
Mega Sage

You can write down after update / Insert BR on incident table with condition like


current.priority.changes() && current.priority == 1



Script Part :


var prob = new GlideRecord('problem');


prob.short_description = current.short_description;


var sysID = prob.insert();



current.problem_id = sysID;



You can refer to "Create problem" UI Action on incident table for more information.



<instance_name>/sys_ui_action.do?sys_id=7cc54e94375e0e00c5486ec2b3990ec2&sysparm_view=ess


saisowmya
Giga Expert

Condition: StatChanges to Resolved and Priority is 1     // At the Time of incident resolution if the incident is a P1 then problem record will be created



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




// Add your code here


if(current.problem_id==''){


var prb=new GlideRecord('problem');


prb.u_ci_category=current.u_ci_category;


prb.u_ci_sub_category=current.u_ci_sub_category;


prb.u_ci_affected_app_infra=current.u_ci_affected_app_infra;


prb.short_description=current.short_description;


prb.description=current.description;


prb.priority=current.priority;


prb.assignment_group=current.assignment_group;


prb.assigned_to=current.assigned_to;


prb.insert();


gs.addInfoMessage('New Problem Record '+prb.number+ ' has been created');


current.problem_id=prb.sys_id;


}


else{



gs.addInfoMessage('A problem '+current.problem_id.number+ ' is already created for this incident');



}




})(current, previous);


Harsh Vardhan
Giga Patron

Hi Prabhat,



as deepak.ingale has already suggested with after business rule that will work perfectly.


i am just adding few points here.


if you will create problem from incident then in problem form there is a related list "Incident" when ever some Problem get created from that incident will attached there.


so here you go try with script below. i tested and it's working perfectly.



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



// Add your code here


var CreateProb = new GlideRecord('problem');


CreateProb.short_description = current.short_description;


CreateProb.cmdb_ci = current.cmdb_ci;


CreateProb.impact = current.impact;


CreateProb.urgency = current.urgency;


CreateProb.priority = current.priority;


CreateProb.company = current.company;


var sysID = CreateProb.insert();


current.problem_id = sysID;


current.setWorkflow(false);


var mySysID = current.update();



gs.addInfoMessage("Problem " + CreateProb.number + " created");


})(current, previous);




I used condition in business rule "When to run" tab.



find_real_file.png



To show the message either you use "Action" tab or gs.addInformMessage() function in script. so i used both of them.



find_real_file.png



incidents.png



Final Result



incidents.png


Hope it will help you.


@Harshvardhan Today I refereed this Thread. Tried this scenario in my PDI.

can you please explain me in brief why we have used 

current.setWorkflow(false);

var mySysID = current.update();

here.

Thanks