Change Label and Help Text of Variable based on value selected

leahp
Kilo Guru

Is there a way to change the help Text and label of a variable based on something selected in another variable?

I have a catalog form that has a field called Collaboration Tool (Lookup Select Box - another table in SN) and a field called Key (Single Line Text).  

If Collaboration Tool = Value Z, Help Text and Label for "Key" field should be ZZZZ.  

If Collaboration Tool = Value X, Help Text and Label for "Key" field should be XXXX

Specific help would be appreciated

2 REPLIES 2

lks
ServiceNow Employee
ServiceNow Employee

Hello Leah,



Instead of changing the Label and Help Text, how is it if you use two variables and display them accordingly using Catalog onChange Client Script based on the value selected in Collaboration Tool.


souren0071
Tera Expert

Hi Leah,



You can change the label of field on the below written onchange client script:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


    //Type appropriate comment here, and begin script below


    if (newValue=='3') {


      var oldLabel = g_form.getLabelOf('comments');


      g_form.setLabelOf('comments', 'Customer visible');


}


  else


  g_form.setLabelOf('comments', 'Additional Comments');


}


In order to change the help text you need DOM manipulation which is not recommended. Instead if you have to do please refer to the below link:



Updating variable help text dynamically?



Regards,


Souren



PS: Hit like, Helpful or Correct if I was able to assist you