- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 01:49 AM
how to fetch the incident attached with problem records through business rule?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 02:59 AM
Hi, you can write a BR on the problem record and you can fetch the records. However be careful if the no. of incidents are high in your system, then this could affect the performance of the system as well.
Create BR on problem record
When: Display
Select Advanced
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.info("problem number is"+current.number);
var inc = new GlideRecord("incident");
inc.addQuery("problem",current.number);
inc.query();
while(inc.next()) {
gs.info("Incident is "+inc.getValue("number"));
}
})(current, previous);
Kindly mark my answer as correct if this works for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:28 AM
Could you tell me if you are facing any error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:31 AM
From incident record i created a problem . after placing the above code in problem it has to display the incident number from which it has ...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:34 AM
The code that i had given above will print the information in the log. Check what data are you getting in the log file.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:36 AM
Try this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.info("problem number is"+current.number);
var inc = new GlideRecord("incident");
inc.addQuery("problem_id",current.sys_id);
inc.query();
var incidents = []
while(inc.next()) {
incidents.push(inc.number.toString());
}
gs.info("Incident(s) is/are "+ incidents);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:43 AM