how to print filed :state value in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017 03:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017 03:24 AM
HI Venkat,
Please use
1) alert(" "+ val); //It will pop up the message.
2)g_form.addInfoMessage('The top five fields in this form are mandatory');// It will show at the top of the page
3)g_form.showFieldMsg('impact','Low impact response time can be one week','info'); // IT will show under the field.
Check : http://wiki.servicenow.com/index.php?title=Display_Field_Messages#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017 05:16 AM
Hi Midun
actually i am trying to print value in state filed,not having issue with above methods,
finally got the solution
var Value = g_form.getValue('state');
var valdata=g_form.getOption('state', Value).label;
g_form.addInfoMessage("valdata"+valdata);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017 04:03 AM
Hi Venkat,
Please try the below code, it will work..
- function onChange(control, oldValue, newValue, isLoading, isTemplate) {
- if (isLoading || newValue == '') {
- return;
- }
var typeValue = g_form.getValue('state');- var typeLabel = g_form.getOption('state', typeValue).label;
- alert(typeLabel);
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2017 05:13 AM
Thanks vinoth its working
1.can you please explain why it was not working for below
var typeLabel = g_form.getOption('state', typeValue);// with out label
2. please let me know in client script what are the all functions available for printing value of fields
i have tried below these are working,
var group = g_form.getReference('assignment_group');
g_form.addInfoMessage("group "+ group.name);
var sd = g_form.getValue('short_description');
g_form.addInfoMessage("shortdesc"+ sd);
3. difference between getValue() and getDisplayValue()