g_form.setLabelOf() not working on Catalog Item in Helsinki

stephaniet
Kilo Expert

I have the following catalog client script created on a Catalog Item.   It is supposed to change the label of the variable 'network_drives' to what is listed below.   I get the alert, so I know the if statement is correct, but nothing happens to the label.   Does anyone know what is wrong here?

I am currently on Helsinki Patch 11.   I have tried setting the UI Type to be only desktop as well and no change.   I've also changed what it applies on so it will only run on the catalog item, and same thing happens.   I have also confirmed the 'network_drives' variable name is spelled correctly.

Applies to: A Catalog Item

UI Type: Both

Type: onChange

Variable name: mirror;

Applies on Catalog Item, Requested Item and Catalog Tasks views

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

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

return;

}

//Type appropriate comment here, and begin script below

if(newValue=='true'){

alert('change label');

g_form.setLabelOf('network_drives','List additional Network Drives or DLs needed');

}

}

5 REPLIES 5

Shahed Shah1
Tera Guru

This function is really intended for Form Fields (I've tested it and it still works) not Catalog Variables. The variables are rendered differently compared to how a form (e.g. viewing an Incident record) is built up.



Having said that, what is the requirement you're trying to fulfill? Perhaps there's an alternative that can be offered.



EDIT: Prateek did good by sharing documentation to highlight it is not supported. As the Wiki is only relevant to releases prior to Geneva, I feel it prudent to share more up-to-date documentation which still highlights the same statement: https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=r_GlideFormSetLabelOf_String_String


This form is for onboarding new or promoted employees.   The original name of the field instructs users to include the network drives or DLs that the person will need to be a part of.   I have given them an option to choose someone else that the new person should be modeled after.   If they choose a model, then I want to change the name of the network drives field to include the word "additional" so that they don't feel like they have to choose someone to model after plus still list drives or DLs needed.


Hmm. Interesting idea.



I'm wondering if it's better to have another variable for this purpose and then switch between them using a Catalog UI Policy. It may also help with reporting, where you can easily determine the types of onboarding requests (modeled vs DLs).



Unless you already thought of this...


Prateek kumar
Mega Sage

Hello Stephanie



This post might help you.


setLabelOf() does not work



Please mark my response as correct and helpful if it helped solved your question.
-Thanks