How to show hyperlink in field message

Talari Balateja
Tera Expert

Hi,

 

How to show hyperlink in field message, I tired with info message, but the requirement is field message. 

 

Script include:

var IncidentHistoryBasedOnPSID = Class.create();
IncidentHistoryBasedOnPSID.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    getIncidents: function() {
        var ps_id = this.getParameter('sysparm_newValue');
        if (!ps_id) {
            return '';
        }
        var incident = new GlideRecord('sn_si_incident');
        incident.addQuery('u_ps_id', ps_id);
        incident.query();

        if (incident.hasNext()) {
            return '<a href="/sn_si_incident_list.do?sysparm_query=u_ps_id=' + ps_id + '" target="_blank">Security Incident History: ' + ps_id + '</a>';
        }
        return '';
    },
    type: 'IncidentHistoryBasedOnPSID'
});
 
 

Client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var a = new GlideAjax('sn_si.IncidentHistoryBasedOnPSID');
    a.addParam('sysparm_name', 'getIncidents');
    a.addParam('sysparm_newValue', newValue);
    a.getXMLAnswer(function(response) {
        g_form.clearMessages();
        if (response) {
            g_form.addInfoMessage('Related Security incidents:<br/>' + response);
        } else {
            g_form.addInfoMessage('No Related Security Incidents');
        }
    });
}
3 REPLIES 3

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Talari Balateja 

You cant add links in the field message


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Voona Rohila
Kilo Patron
Kilo Patron

There are few alternatives, take a look at below links

https://www.servicenow.com/community/developer-forum/can-we-add-a-html-link-in-showfieldmsg/m-p/1725...

https://www.servicenow.com/community/developer-forum/to-create-hyperlink-in-client-scripts-showfield...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP