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.

HTML Help text

Brian Lancaster
Kilo Patron

Does anybody know of a way to make it so that HTML shows in the help test now that ServiceNow is escaping it?   We obviously do not want to set glide.ui.escape_text to false.   Just wondering if there are any other workarounds before we have to upgrade to Fuji Patch 12 Hot fix 1.   We have tables setup to show what the different choices mean on a list collector.

37 REPLIES 37

Carlos Caldero1
Tera Contributor

Hello Brian,



I saw your question and I know that this is a little bit old, but I have a solution for your problem, I have created the following function to solve the issue in Fuji without modifying any system property and it works fine for me.



The only way to do this is using DOM manipulation using an onLoad script, this is not recommended by ServiceNow but sometimes we have to implement the changes in this way to fulfill the requirements.



Just pass the name of your variable in the parameter of the function unescapeHelpText inside the onLoad script created, and the code will do the magic for you:



function unescapeHelpText(pField)


{


  //Set the name of the field in the 'field' variable


  var field = pField;



  //Append the table name to get the field id


  field = g_form.getControl(field).id;



  var vId = field.toString().replace(/sys_original./g, '');



  //Construct the id of the container of the help text


  var vHelpID = 'help_' + vId + '_wrapper';



  //alert(vHelpID);



  //Get escaped HTML code


  var vEscapedHelpText = document.getElementById(vHelpID).innerHTML;


  //alert('vEscapedHelpText:\n' + vEscapedHelpText);



  //Replace escaped characters


  var vHelpText = '';


  vHelpText = vEscapedHelpText.toString().replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/  /g, ' ');



  //alert('vHelpText:\n' + vHelpText);



  document.getElementById(vHelpID).innerHTML = vHelpText;


}



Hope this code help you.



Regards!


Sorry I thought I had marked this as answered.   When we were on Fuji I found this code the fixed the issue in an Onload script


$j(function($){  


      $('table.help_table td:first-child:not([data-htmlized=true])').each(function(){  


              var help = $(this);  


              help.data('htmlized','true').html(help.text());  


      });  


});



When we moved to Helsinki we had to update the code to this which was provided by Venkat Iyler.


$$("div.sc-help-text").each(function(item){  


  var textValue = item.innerText;  


  $(item).update(textValue);  


});



Is this still working for you?

I used the same script and now its throwing a dirty form error message.

 

Thanks,

Jocelyn