Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Can i change the label of a variable in form.

Naresh291
Tera Contributor

Hi,

I have a variable 'Requested for' which is a variable in variable set . My requirement is that for a particular form , this requested for variable label should be changed to 'Owner name'  .

Is on load client script the correct approach .

And if this is so , then will it also change the database name of the variable . I dont want the database name of requestd for i.e. requested_for to change . But only the label to be changed to 'Owner name''

 

Any leads on this is highly appreciated .

Regards,

Naresh

6 REPLIES 6

AlpUtkuM
Mega Sage

You can use OnLoad client script 

 

g_form.setLabelOf('your variable',"the label you want to set") ;

Pranav Bhagat
Kilo Sage

Use the OOB setLabel of

g_form.setLabelOf('requested_for',"owner") ;
 
If the above doesn't work then use the onload client script script with DOM Manipulation
 

Simran5
Kilo Expert

Hey,

You can create an onload client script and use g_form.setLabel() method.

 

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

this reference might help you more

 

Mark helpful

 

Thanks & Regards 

Simran

Ankur Bawiskar
Tera Patron

@Naresh29 

For portal you will have to use DOM manipulation so I won't recommend that.

Why not take this approach

1) Hide that variable for your particular catalog item

2) create new Label variable with Label as "Owner name"

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader