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.

Musab Rasheed
Tera Sage

Hello,

 

I have often seen this basic question about fetching display value of choice field so here is the working short solution.

 

If we use getValue it will show only backend value of Choice value but below code will display front end value of Choice.

 

function onLoad() {
   //Type appropriate comment here, and begin script below

   var storevalue = g_form.getValue('impact');
   var storedisplayvalue = g_form.getOption('impact',storevalue).text;
	alert(storedisplayvalue); //Alert to display when form loads
}

 

Please hit like if this solution helps.

 

Comments
luffy3478
Tera Guru

Hi Musab,

 

The script did not work for me. I am receiving the error "Uncaught TypeError: Cannot read properties of null (reading 'text')"

mugi-san
Tera Guru

Hi, @luffy3478 .

Please try this script.

g_form.getOption('impact', storevalue).textContent;
Version history
Last update:
‎12-31-2024 10:01 AM
Updated by:
Contributors