how to fetch the incident attached with problem records through business rule?

jiu
Kilo Contributor

how to fetch the incident attached with problem records through business rule?

1 ACCEPTED SOLUTION

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.

View solution in original post

19 REPLIES 19

In the place of release_id use the field name on the change form that is relating to release

Sanjay Bagri1
Tera Guru

Hi ,

you can use this code in Display buisiness rule.

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

    // Add your code here
    
    var inc = new GlideRecord("incident");
    inc.addQuery("problem_id",current.sys_id);
    inc.query();
    while(inc.next()){
    //gs.addErrorMessage("Row count "+ inc.getRowCount());
    gs.addInfoMessage("Incident is :-  "+inc.number );
    }

 

it will show you only how many incidents are participates in problem .

and it can do also through After BR .

Please remember it mark as correct and helpful

Thanks

Sanjay Bagri

here these three incident are in problem

 

 

find_real_file.png

 

 

This is a incident see below file only those incident is showing in top

find_real_file.png

 

 

i hope this will help you .

Thanks

 

 

Thanks

 

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);

dvp
Mega Sage
Mega Sage

Hey

Any update on this?

If one of the responses provided above resolve your question, please mark the response as correct answer, so future readers can find solution easily.