AnveshKumar M
Tera Sage

Hi @vinod6 

Can you elaborate the requirement? 

 

Are you trying to display an info message if an Incident that belongs to that particular problem is resolved? If yes try the below Display Business Rule.

 

AnveshKumarM_0-1701682131429.png

 

AnveshKumarM_1-1701682169640.png

 

AnveshKumarM_2-1701682198534.png

 

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

    var incGr = new GlideRecord("incident");
    incGr.addEncodedQuery("problem_id=" + current.getUniqueValue() + "^state=6");
    incGr.query();
    while (incGr._next()) {
        var link = '<a href="' + incGr.getLink() + '">' + incGr.getValue('number') + '</a>';
        var message = gs.getMessage('Incident Resolved') + ' ' + link + ' ';
        gs.addInfoMessage(message);
    }

})(current, previous);

 

If you want to display Closed incidents also, try below code.

 

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

    var incGr = new GlideRecord("incident");
    incGr.addEncodedQuery("problem_id=" + current.getUniqueValue() + "^stateIN6,7");
    incGr.query();
    while (incGr._next()) {
        var link = '<a href="' + incGr.getLink() + '">' + incGr.getValue('number') + '</a>';
        var message = gs.getMessage('Incident Resolved') + ' ' + link + ' ';
        gs.addInfoMessage(message);
    }

})(current, previous);

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh