Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Insert Link in field msg

Kanika4
Tera Contributor

Hi All,

I have a requirement where I need to show below field msg based on the selection

 

 

Please proceed with a request for a single use or multi-use card which can be used for both online and tap and go transactions. Click on the below link to see how

<insert link>

 

I can achieve the text through showFieldMsg() but how can I insert a link in there ?

3 REPLIES 3

Runjay Patel
Giga Sage

Hi @Kanika4 ,

try with below code.

showFieldMsg("Please proceed with a request for a single use or multi-use card which can be used for both online and tap and go transactions. Click on the link below to see how: <a href='https://www.example.com' target='_blank'>See how</a>", 'info');

 

Accept the solution if it helped.

Not working. This is how it came up on the field

 

Kanika4_0-1732573311050.png

 

Ranjane_Omkar
Kilo Sage

Hello @Kanika4,

 

It is not possible using g_form.showFieldMsg("<a href='https://www.google.com> See how </a>" ) etc. You can do it using alternative method like DOM manipulation.

 

Try the  below code. Make sure isolate script is unchecked on the client script.

 

 

function onLoad() {
    g_form.showFieldMsg('short_description', "This will be replaced with below ", 'info');

    var x = gel('incident.short_description_fieldmsg'); // <table_name>.<field_nam>_fieldmsg

    x.innerHTML = '<div class="fieldmsg-container" id="incident.short_description_fieldmsg" aria-live="polite"><div class="fieldmsg notification notification-info">' + 'Please proceed with a request for a single use or multi-use card which can be used for both online and tap and go transactions. Click on the below link to see how <a href=' + '"https://google.com"' + 'target="_blank"' + '>' + 'This will link out to Google' + '</a>' + '</div>' + '</div>';
}

 

 

 

I have done it on short description field from incident. Refer below screenshot.

Ranjane_Omkar_1-1732612353700.png

 

Update the code as per your requirement.

 

Regards,

----

If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.