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.

On Load client script

anupsad
Tera Contributor

When i trying to show an alert for incident table with state

function onLoad() {
    var currentstate=g_form.getValue("state");
  alert("current state is:  " + currentstate);
 
Am only getting the numerical value assigned to that dropdown. My requirement is to show the actual stte value.
Can anyone please help me
2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

You would need to call a Script Include via Glide Ajax, passing in the State value and returning the corresponding Label.  Here's an excellent guide to walk you through it

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

Najmuddin Mohd
Mega Sage

Hi @anupsad ,

Use g_form.getDispalyValue('state') instead of g_form.getValue('state') to get the front end value.
g_form.getDisplayValue returns the front end value
g_form.getValue returns the backend value.


If this information helps you, kindly mark it as Helpful and Accept the solution.

Regards,
Najmuddin.