Display list of incidents of logged in user and show it on page using gs.addinfomessage()

lakshmi75
Tera Contributor

I have a requiremenet to Create a Business Rule that will output information about Incidents with the same Caller. When a new Incident is created, search the database for other Incidents that have the same value in the field Caller and use gs.addInfoMessage() method to display their Numbers at the top of the page.

1 ACCEPTED SOLUTION

@lakshmi

Try this:

(function executeRule(current, previous /*null when async*/ ) {
    var arr = [];
    var grI = new GlideRecord("incident");
    grI.addQuery("caller_id", current.getValue("caller_id"));
    grI.addActiveQuery();  //use this to return active incidents
    grI.query();
    while (grI.next()) {
        arr.push(grI.getValue("number"));
    }
    gs.addInfoMessage("Caller Incidents are:" + arr.toString());

})(current, previous);

Hope it helps

 

Thanks,

Murthy

Thanks,
Murthy

View solution in original post

9 REPLIES 9

Murthy Ch
Giga Sage

Hi Lakshmi,

You can use after insert BR on incident table.

Have you written anything?

 

Thanks

Murthy

Thanks,
Murthy

lakshmi75
Tera Contributor

Hi,

I have tried afert insert Br and glided incident table and gave conditions for matching current caller_id .

But failed to display list of incidents.

 

Thanks,

Lakshmi.

Can you share your script?

Thanks,
Murthy

@lakshmi

Try this:

(function executeRule(current, previous /*null when async*/ ) {
    var arr = [];
    var grI = new GlideRecord("incident");
    grI.addQuery("caller_id", current.getValue("caller_id"));
    grI.addActiveQuery();  //use this to return active incidents
    grI.query();
    while (grI.next()) {
        arr.push(grI.getValue("number"));
    }
    gs.addInfoMessage("Caller Incidents are:" + arr.toString());

})(current, previous);

Hope it helps

 

Thanks,

Murthy

Thanks,
Murthy