Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Value return error in widget

KiranmaiP
Tera Contributor

Can we add getValue() with field value of type "String"?

Is it getDisplayValue() or getValue()?

1 ACCEPTED SOLUTION

_Tushar Soni
Kilo Sage
Kilo Sage

Hello @KiranmaiP ,

Yes, you can use getValue() with a field of type String.

 

getValue() - Retrieves the actual value stored in the database
Example: When you need the raw data, like a sys_id or the exact value of a field.
var fieldValue = g_form.getValue('field_name');

 

getDisplayValue() - Retrieves the human-readable or display value that users see.
When you need the name, label, or description that is shown in the UI, especially for reference fields.

var displayValue = g_form.getDisplayValue('field_name');

 

If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!

View solution in original post

2 REPLIES 2

_Tushar Soni
Kilo Sage
Kilo Sage

Hello @KiranmaiP ,

Yes, you can use getValue() with a field of type String.

 

getValue() - Retrieves the actual value stored in the database
Example: When you need the raw data, like a sys_id or the exact value of a field.
var fieldValue = g_form.getValue('field_name');

 

getDisplayValue() - Retrieves the human-readable or display value that users see.
When you need the name, label, or description that is shown in the UI, especially for reference fields.

var displayValue = g_form.getDisplayValue('field_name');

 

If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!

Pratiksha_kadam
Tera Contributor

Hi Varun,

 

Please go through  this article: https://www.servicenow.com/community/in-other-news/how-to-use-getdisplayvalue-and-getvalue-for-glide...

I hope this will help you.

Please mark helpful if I answered correctly.