- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2019 11:09 PM
Hi Team,
On INCIDENT Table, there's a custom field drop-down 'Primary Root Cause' and if drop down value is chosen as 'To be investigated via PROBLEM record' , it automatically creates a PROBLEM record on Resolution of Incident. The problem is if we have 'x' number of Child Incidents linked with a PARENT INCIDENT, it creates 'x' number of Problem tickets because the primary root cause field value flows from Parent incident to Child incident.
The requirement is -
If there are child incidents attached to a Parent incident, and the Primary Root Cause is chosen as To be investigated via PROBLEM record, it should only create 1 Problem record, and all the subsequent child incidents should get attached to this Problem ticket.
How can we achieve this via a Business rule?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2019 09:48 PM
Hi Rookie,
Please try this code in your BR on Incident table, remove the condition Problem is empty in your condition and check that in code directly. -
if(current.problem_id == ""){
var generateProblem = new CreateProblemFromIncident();
generateProblem.createProblem();
current.update();
}
if(current.problem_id != "")
{
var chkNum = new GlideRecord('incident');
chkNum.addQuery('parent_incident',current.sys_id);
chkNum.query();
while(chkNum.next()){
chkNum.problem_id = current.problem_id;
chkNum.update();
}
}
Kindly mark helpful/resolved if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2019 11:24 PM
Hello SN,
I guess, you are using a AFTER Business rule to resolve a ticket and create a problem record. You need check below things and then you should create a problem:
1.Check if parent field is empty. If yes, add a code to create problem
2. In same business rule, first find out all the child records and attach it to the problem code.
Let me know if you face any issue while coding. If possible, I will share my code with you.
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2019 11:35 PM
Hi Abhishek,
Thanks for the reply.
Below is my After Insert/Update Business Rule -
Condition - 1. Primary Root Cause = To be investigated via PRB
2. Problem is empty
Code -
(function executeRule(current, previous /*null when async*/) {
var generateProblem = new CreateProblemFromIncident();
generateProblem.createProblem();
current.update();
})(current, previous);
This calls a customised Script include and creates a PRB ticket.
Can you pls share your code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2019 11:59 PM
Hello SN
1. I have created a new business rule as below:
Business Rule script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var grProblem = new GlideRecord('problem');
grProblem.initialize();
grProblem.first_reported_by_task = current.sys_id; // this field is OOTB available on problem to identify from which incident it is created.
grProblem.short_description = current.short_description;
grProblem.description = current.description;
//add field that you want to copy from incident
grProblem.insert();
gs.setRedirect(grProblem);
gs.addInfoMessage(""+grProblem.sys_id);
})(current, previous);
2. With out of the box configuration, Parent is a field available on incident and its get filled if we are adding incident to another incident. So considering this for parent ticket, Parent field is empty.and for child tickets, you can have parent incident number in Parent field.
3. I have added a choice Primary Root Cause for creating a problem as per your scenario.So you can remove that condition and add your custom field IS Primary Root Cause.
Try adding given code and let me know if any issues.
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2019 12:20 AM
Abhishek,
In this code, where is it copying the child incidents to PRB record?