g_form.SetValue() not working in Service Portal (Kingston patch3)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2018 02:22 AM
Hi Everyone,
I am using a basic g_form.setValue function for a catalog item variable.
Eg:-
function onLoad() {
//Type appropriate comment here, and begin script below
//var a = g_form.getValue('test_name');
g_form.setValue('comments',new Date());
//alert(g_form.getValue('choice'));
}
When I test the catalog item from the Service Catalog, this code is working. However, when trying to test within Service Portal, it's not able to set up the field values.
I tried hardcoding the value and even use the values of some other field, but it is not populating the field on the service portal.
Note: Our instance recently upgraded to Kingston.
Kindly suggest a solution for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 10:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2018 11:45 PM
Hi, sorry for the late reply. The GlideAjax we have added calls a script include to retrieve server values.
You can look at the following:
https://docs.servicenow.com/bundle/helsinki-application-development/page/script/server-scripting/reference/r_GlideAjax.html
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 07:53 AM
I'm struggling with this too and I'm on Kingston patch 6 in both Dev and Test where this issue is occurring. This is the most recent patch available as I write this, so it's not fixed yet apparently.
I've had partial success using setValue on some types of variables but its behavior on checkboxes is broken.
I'm using a very simple Catalog UI Policy that should set one checkbox 'skype' to true if another checkbox 'email_account' is set to true. The policy is set to run in 'All' UI types.
It appears that what it's doing in the portal is very rapidly applying the 'true' value to the checkbox (as evidenced by noticing that a separate policy to show a third option does in fact get triggered, and only gets triggered by the target checkbox being set to 'true'), but the 'true' setting on the target 'skype' field is not staying put.
It works fine in ESS.
I'm calling HI now to find out more. Maybe this is in Patch 7. /shrug

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 10:44 AM
HI support pointed me to this page and explained that I need to add quotation marks around the 2nd parameter, even though it's a Boolean value.
So I changed my Policy script from this...
function onCondition() {
g_form.setValue('skype',true);
}
to this...
function onCondition() {
g_form.setValue('skype','true');
}
And it worked just fine.
They also noted that it wasn't always this way, and "created PRB1290254 to have this issue addressed, since there was a change in behavior." And a bit later the gentleman working the case called and said he expects to be publishing a KB about this too. 🙂
Meanwhile I hope this helps others w/ this issue. (Ayushi - feel free to mark this is the correct answer of course if it helped you.)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2018 02:46 AM
Hi All,
I a also facing same issue on portal, particularly on dot walked fields.
We are on patch 7 but issue persist.
Any help would be appreciated!
Thanks,
Anil
Thanks
Anil Lande