How do I modify the Help Label of Form Fields With Client Scripts?

lesnettl
Tera Contributor

How do I modify the Help Label of Form Fields With Client Scripts? I have a requirement that I dynamically modify the label of a variable in the Service Catalog. I have found plenty of help to accomplish this:

https://community.servicenow.com/message/714821

http://www.servicenowguru.com/system-ui/ui-scripts-system-ui/modifying-label-form-fields-client-scri...

http://www.servicenowguru.com/system-ui/field-styles-service-catalog-variables/

With the suggestions in these resources, I am able to modify the label using Catalog Client Scripting. But I can't figure out how to dynamically modify the help label (normally shown as "More Information" adjacent to the label). Does anyone know how to do this?

Thank you!

1 ACCEPTED SOLUTION

Hi Larry,



Try this



var variableID = g_form.getControl('variableName').id;


var labelElement =   gel('help_'+variableID +'_wrapper');


labelElement.select('td').each(function(elmt) {


              if(elmt.className == '')


                elmt.innerHTML = "What text you want";


          });



Thanks and regards,


Pratik Limbore


View solution in original post

13 REPLIES 13

Jim Coyne
Kilo Patron

It could be done with this bit of JavaScript in a Catalog Client Script:



try{


      var helpId = "label_help_" + g_form.getControl("your_variable_name_here").name.toString();


      var control = $(helpId);


      control.innerHTML = control.innerHTML.replace("More information", "whatever text you want");


} catch(err) {}



The problem is if you have to modify it repeatedly, you'll have to keep track of what you keep changing it to.



I'm wondering if you could use a Field Message instead - http://wiki.servicenow.com/index.php?title=Display_Field_Messages.   It would be less of a hack and less prone to problems.


Thanks, Jim. I talked with my customer and they agreed that your suggestion to use a Field Message would be an acceptable approach. We will leave the More Information off of the field and just use an info message.


You are welcome.   Could you please click the "Correct Answer" button on the appropriate response so others can see that you've found an acceptable answer to your question.   Thanks.


I try to use as much out of the box functionality as I can in order to avoid upgrade issues in the future.