
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 01:43 PM
I have a true/false field. I need to see the value so I can do an If script when it is true.
If I do: var ip = g_form.getValue('u_ip');
The alert is blank.
If I do var ip = g_form.getBoolenValue('u_ip');
The alert returns false regardless of it being true or false.
I can't do display value because that gives me the Case Number.
Any magic I am missing.
Thanks,
Stacy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 02:05 PM
Hi, syntax looks ok and it works correctly for me if I paste to my instance (after updating the reference field).
Is you field visible on your form?
Is the script 'Active' ?
Is script in correct scope?
If are you domain seperated, is domain correct?
Do you have the correct table selected for the script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 01:48 PM
This link may help you. Sometimes with ServiceNow the string of true/false can be returned instead of the boolean value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 01:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 01:50 PM
Hi, var ip = g_form.getValue('u_ip'); would appear to be correct sytax,
and an alert shoudl be failry striaght forward.
https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideFormAPI#r_GlideFormGetValue_String?navFilter=getvalue
From the client\form side true\false will be 'text' not actually bool, so if you are validating a value you would need something like (newValue == 'true')
Perhaps you can share your script so that we can see the context of your issue?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2021 01:58 PM
This is a simple onLoad script to display an alert if this value is true.
function onLoad() {
var ip = g_form.getValue('u_ip');
alert(ip);
if (ip == 'true') {
alert("Hello World");
}
}
Thanks,
Stacy
is your Boolean field is present on the form section??