- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 09:49 AM
Trying to use the Text value from a variables choice, chosen on a service catalog form, in a Catalog Client Script and getting nowhere. The idea is to generate a text box string based on the values the user is filling out on the form that they can view and modify, if needed.
Using an onChange Catalog Client Script where 'subject' is the string to be build out and 'category' and 'system' are the variables on the form they are filling out but 'category' is a choice field and we want to be able to use the Text value on that choice field on the setValue string. getDisplayValue is not working.
var cat = g_form.getValue('category');
var system = g_form.getValue('system');
g_form.setValue("subject", 'Outage: ' + cat + ' for ' + system);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 01:09 PM
Replace your code with below:
var cat = g_form.getControl('category');
var catVal = cat.options[cat.selectedIndex].text;
var system = g_form.getValue('system');
g_form.setValue("subject", 'Outage: ' + catVal + ' for ' + system);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 12:56 PM
remove below from your code.
var cat = g_form.getDisplayBox('category').value;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 01:05 PM
Ok, so the alert is now giving me the variable text value! But when I try to use that line to set the value, I get [object HTMLSelectElement] in the string (i.e. Outage: [object HTMLSelectElement] for System Name):
var cat = g_form.getControl('category');
var system = g_form.getValue('system');
g_form.setValue("subject", 'Outage: ' + cat + ' for ' + system);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 01:09 PM
Replace your code with below:
var cat = g_form.getControl('category');
var catVal = cat.options[cat.selectedIndex].text;
var system = g_form.getValue('system');
g_form.setValue("subject", 'Outage: ' + catVal + ' for ' + system);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2016 01:16 PM
Hardik... you are a rock star! Thanks for your perseverance and patience, you made my day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 09:05 AM
var option = g_form.getControl('option');
var optionVal = option.options[option.selectedIndex].text;
var test= confirm("Option: " + optionVal );
Thanks!