how to print filed :state value in client script

venkatrajesh
Tera Expert

State values: open,closed,pending change,known error

i have tried

var val = g_form.getValue('state');

g_form.addInfoMessage("state "+ val);    

--->getting 1/2/3 depending on state value

to get numeric value     var val=g_form.getIntValue('state'); is enough

so how to print state filed value in text ex:pending change

6 REPLIES 6

Hi Venkat,



I have worked earlier, so I have just did. In general earlier statement will pick up the choice list value record and we are just taking the label values You can rename the label to text also. It will also work



http://wiki.servicenow.com/index.php?title=Client_Scripts#gsc.tab=0


find_real_file.png



2) g_form.showFieldMsg, alert, g_form.showErrorBox() are available.



Refere Scripting Alert, Info, and Error Messages - ServiceNow Wiki for more info



3) g_form.getValue() used to get the values in the client side and getDisplayValue() is used at server side, normally while doing gliderecord operaration.



Please mark my answer as correct, if it answer your query


lSurya 24
Giga Guru

Hello Venkat,



try this:



var val = g_form.getDisplayValue('state');


g_form.addInfoMessage("state "+ val);