How to add hyperlink into info message on problem table

vinod6
Tera Contributor

For example, when a certain incident record is "resolved" we get an info message into the problem table

 

vinod6_0-1701681065856.png

Please help any one.

Please send the script. It is very helpful for me.

 

2 REPLIES 2

Peter Bodelier
Giga Sage

Hi @vinod6 

 

You can simply add html in the message. Something like

 

//incident part provided as bascix example
var inc = new GlideRecord('incident');
inc.insert();

var url = '<a href="./incident.do?sys_id=' + inc.sys_id + '>' + inc.number + '</a>';
gs.addInfoMessage('Incident ' + url ' + ' has been created.');

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

AnveshKumar M
Tera Sage
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