g_form.getDisplayValue('priority') not fetching displayed priority value of current open incident

DPP1
Tera Contributor

Hi SysAdmin Forum

 

I am trying the below but am not being successful, need assistance !!

 

g_form.getDisplayValue('priority') not fetching displayed priority value of current open incident form's priority field

 

it is instead fetching the displayed incident number value of current open incident form's incident number field

 

Below is the code snippet that I am trying to use ->

 

=====

var priority2 = g_form.getDisplayValue('priority');
g_form.addInfoMessage(" Priority of the incident is " + priority2 );
=====

 

-----

Note ->

 

I have tried using g_form.getValue('priority') which is fetching the numerical priority value of the current open incident form's priority field

-----

 

I need to fetch the current incident form's priority field's displayed value and not its numerical value.

 

Thanks in advance for the help.

 

DPP

2 ACCEPTED SOLUTIONS

Vishal Jaswal
Giga Sage

Hello @DPP1 

 

getDisplayValue() is suitable for reference type field values. For example, caller field value of the incident form.

 

You should try below:

 

var priorityValue = g_form.getValue('priority'); // Gives you the numeric value (like 1, 2, 3, 4)
var priorityDisplay = g_form.getOption('priority', priorityValue).text; // Gets the display value

g_form.addInfoMessage("Priority of the incident is " + priorityDisplay);

 

Hope it helps!


Hope that helps!

View solution in original post

Medi C
Giga Sage

Hi @DPP1,

 

Please use:

var value = g_form.getValue('priority');
var displayValue = g_form.getOption('priority',value).text;

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

View solution in original post

6 REPLIES 6

Viraj Hudlikar
Tera Sage

Hello @DPP1 

 

GlideForm - getOption(String fieldName, String choiceValue)

Returns the option element for a selected box named fieldName where choiceValue matches the option value.

 

Documentation Link - 

https://www.servicenow.com/docs/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_refe...

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Thanks Viraj for the information in the context of my query.