Add value to list variable in client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2014 05:31 AM
Hi,
please let me how to add values in to list variable in client script.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2014 01:48 PM
The list variable is just a comma separated list of values so to add a value, either just make the variable equal to something
g_form.setValue("list", "red,blue,green");
or add in an additional value with
var list = g_form.getValue("list");
list += "yellow";
g_form.setValue("list", list);
See the wiki for details. GlideForm (g form) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2014 02:06 PM
The question is why do you want to do it via Client Script versus populating the values from a table? From the maintenance perspective, every time you need to change or add new values to the list, you will have to touch the client script, versus doing it via data maintenance on the table.
I am just curious ....