How do I refer to variables in variable sets in a client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2014 01:48 PM
I have a variable which is the only variable in a variable set. I am trying to modify this variable using a client script (g_form.setValue()) but it isn't working. I have another variable which is not in a variable set and that one can be set through g_form.setValue() in a client script. Currently I am referring to the variable in the set like this: g_form.setValue('<variable>','<value>','<display>') but I have also tried g_form.setValue('<variable set>.<variable>','<value>','<display>') and g_form.setValue('variables.<variable>','<value>','<display>') but none of these works. What is the proper syntax for this reference?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2014 04:20 PM
I've always run them on the catalog item without issue.
So you have a catalog item with a variable set containing a select box.
A select box will not play nicely with g_form.setValue(). Since it is essentially a choice list with each line being an option, you will have to use a combination of the following to get what you want:
g_form.clearOptions('variable');
g_form.addOption('variable','value','label','index'/*the line-space in the box where you want this option to show*/);
g_form.removeOption('variable','value');
From:
http://wiki.servicenow.com/index.php?title=GlideForm_%28g_form%29
'6 Change Choice List' Section
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2014 08:41 AM
This is what I currently have:
function onSubmit() {
//Type appropriate comment here, and begin script below
alert('SCRIPT EXECUTING');
g_form.setValue('action.action', 'remove_access', 'remove access');
}
I have changed the variable type to single line text but it still isn't working. The script applies to the catalog item and it is executing (according to the alert) when expected. The value of action is still not being assigned. I have tried both action and action.action (action is the name of both the variable set and the variable)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2014 09:24 AM
Do you have this working yet?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2014 09:30 AM
Honestly, I got diverted onto another task and haven't been focusing on this. But no I have not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2014 09:32 AM
What is the type of variable are trying to set?