setLabelOf not working

kailashthiyagar
Kilo Guru

I m working on a service catalog where i set the catalog item label , using setLabelOf, but unfortunately its not working. In one of the older post, its been mentioned it will not work in Service catalog. does it hold true? If so, how could we achieve it in service catalog?

I m using Fuji , i believe patch is 11

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

Hi Kailash,



I also thought it should work but apparently it doesnt. With the function below you should be able to change label names and also raise a Hi ticket.



/**
* Description:   Code that could be applied to change the label in Service catalog item
* Parameters: field name, value to be set
* Returns: Sets the label
*/


function setLabelOfInServiceCatalog(fieldName, value) {
var fieldId = g_form.resolveNameMap(fieldName);
var label = gel('label_' + fieldId);
$j(label).text(value);
}


View solution in original post

4 REPLIES 4

rakesh_ravi
ServiceNow Employee
ServiceNow Employee

I don't think setLabelOf is not supported on the service catalog. It is only supported on the table forms.


If it is absolutely necessary, you will have to go via DOM manipulation route.



Hope this helps.


venkatiyer1
Giga Guru

Hi Kailash,



I also thought it should work but apparently it doesnt. With the function below you should be able to change label names and also raise a Hi ticket.



/**
* Description:   Code that could be applied to change the label in Service catalog item
* Parameters: field name, value to be set
* Returns: Sets the label
*/


function setLabelOfInServiceCatalog(fieldName, value) {
var fieldId = g_form.resolveNameMap(fieldName);
var label = gel('label_' + fieldId);
$j(label).text(value);
}


Thanks Venkat..


For anyone finding this in the future, be sure to set the Isolate Script field on the Client Script to false else the above code will not work.