- 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:44 AM
var inc = new GlideRecord("incident");
inc.addQuery("problem",current.sys_id);
inc.query();
var incidents = []
if(inc.next()) {
incidents.push(inc.number.toString());
}
gs.addInfoMessage("Incident(s) is/are "+ incidents);
But its not matching with incident

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:47 AM
please replace the line
inc.addQuery("problem",current.sys_id);
with
inc.addQuery("problem_id",current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:50 AM
thanks 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 03:56 AM
Did it work?
Please close this thread by marking the correct answer!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 04:04 AM
in Release , if I add Change request but getting some other record , can u help me in dis
var chg = new GlideRecord("change_request");
chg.addQuery("release_id",current.sys_id);
chg.query();
var change = []
if(chg.next()) {
change.push(chg.number.toString());
}
gs.addInfoMessage("Change(s) is/are "+ change);