How to get the Variable-Question Text in a Script?

Meloper
Kilo Sage

Hi,

how can i get the Questiontext of a Variable in a script

find_real_file.png

not the Value, only the Question!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is this for client side or server side?

For server side:

current.variables.<var_name>.getLabel()

For client side:

g_form.getLabelOf('var_name');

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

4 REPLIES 4

Adrian Ubeda
Mega Sage
Mega Sage

Hi, 

Try g_form.getLabel('field_name'), this will output the label of the field referred. Also, you use setLabel to set custom label as you want.

If it was helpful, please give positive feedback.
Thanks, 

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Is this for client side or server side?

For server side:

current.variables.<var_name>.getLabel()

For client side:

g_form.getLabelOf('var_name');

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

both

Meloper
Kilo Sage

also possible with current.variables.%NAME%.getLabel(); for Serverside