Render g_form.showFieldMsg with HTML

The SN Nerd
Giga Sage
Giga Sage

I want to output a g_form.showFieldMsg with a word in bold.

I have tried using UI Messages, ${AMP}, < & > to no avail.

Can this be done cleanly?


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
5 REPLIES 5

Manjul Katare
ServiceNow Employee
ServiceNow Employee

Hi Paul,



One way you can achieve it through client script:


I was able to make the error message text size bigger.



function onLoad() {


      g_form.showFieldMsg('number','Hello World!','error');


  if($j('div.notification-error').length){


    $j('div.notification-error').css('font-size','20px');


  }


}




find_real_file.png



As per wiki, I should also be able to do the same with below properties but for some reason it didn't work for me (may be it works for older releases).



The css.outputmsg.info.text.font-size property sets the size for info messages. Default is 11pt


The css.outputmsg.error.text.font-size property sets the size for error messages. Default is 11pt



Hope it helps!


-Manjul


I'm looking to make one word in a sentence bold/strong without direct DOM manipulation.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

katherinelewis1
Tera Contributor

The short answer is No, this cannot be done with the g_form.showFieldMsg function.



If you look at the source code for the function you can see the message is added to the DOM as a '#text' node type; which does not support processing embedded mark-up.



    var fieldMsgRow = doc.createElement('DIV');


    fieldMsgRow.className = msgClass;


    fieldMsgRow.hasFieldmsg = true;


    var fieldmsgMsg = doc.createTextNode(message);


    fieldMsgRow.appendChild(fieldmsgMsg);


    fieldMsgContainer.insert(fieldMsgRow);



I hope this helps.