How to dinamically change the label of a question in a catalog item?

Juan R_ Campos
Giga Contributor

Hi Community,

I need to change the label of a question in a catalog item depends of the option the user choose in a Select Box, I want to use the same field to capture the information and do not create a lot of fields to do the same function.

I created a Catalog Client Scripts and tried with g_form.setLabelOf but it is not working.

var varValue = g_form.getValue('subcategory');    

      if(varValue== '2'){

    g_form.setLabelOf('specifySubCategory', 'New Value')');

      }


Do you know any other way to make this change?

Regards,

Juan

1 ACCEPTED SOLUTION

Try



jQuery("label[for='"+g_form.getElement('user').id+"']").html("YourText");



Replace user with your variablename


View solution in original post

13 REPLIES 13

manikorada
ServiceNow Employee
ServiceNow Employee

Juan,



If you check this link : http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf


It states that setLabelOf() is not supported in catalog item.


I noticed, that's why I am looking for an alternative way to do it.


tonyshabani
Kilo Expert

You're better off creating separate variables and setting the visibility to true via UI Policies.



Service Catalog UI Policy - ServiceNow Wiki



Regards,



Tony


Thanks but this is what I don't want to do, because I will need to create a lot of variables and support the form will be so difficult later.