We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

How to get field label from field name?

tahnalos
Kilo Sage

For any field in a GlideRecord, what is the method used to grab the label name?

Thanks

11 REPLIES 11

TzachB
Giga Contributor

hey,

try to use gr.[field name].getLabel();

Twist: I'm being fed a bunch of field names through an array, and I need to get the field labels for them.  How do I leverage getLabel to get the label from an array that is dynamically passed?

Well, in that case iterate over the array (let's call it arrFields) and use 

gr.getElement(arrFields[i]).getLabel();


If this post was helpful, I would appreciate if you marked it as such - thanks!

Best
Daniel

Worked like a charm!