- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2016 09:25 AM
I have a checkbox and a list collector(glide_list) on a catalog item. if the checkbox is checked(true), the glide_list is visible(via UI policy). If the requestor adds items to the glide_list but then unchecks the checkbox, I want to clear the contents of the glide_list.
In the JavaScript Executor, I have run the following:
var a = g_form.getValue('IO:81332e394f2ae200b8ec7f75f110c77e');
alert(a);
var b = [];
g_form.setValue('IO:81332e394f2ae200b8ec7f75f110c77e', b);
Lines 1&2 successfully collect the contents of the glide_list and display them as a comma-separated list of sys_ids, as expected. Lines 3&4 appear to successfully set the value of the field to an empty string, however, the display values remain in the field. If I run lines 1&2 again, the alert appears to return nothing.
Additionally, I have an onSubmit client script that shows an error message if the checkbox is checked and the glide_list is empty. If I run the above code and click Submit, the error message appears, as if the glide_list is empty, even though the display values remain.
Is there another way to clear the contents of a glide_list using a client script? Or do I need to find some way to re-render the glide_list after I've cleared it out?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 08:24 AM
Patrick,
Here is what I did:
First, open your catalog item, right-click the window portion that holds the items you select, then click Inspect.(assuming you are using Chrome)
Look for the "name" attribute, should look something like:
name="select_0IO:81332e394f2ae200b8ec7f75f110c77e"
Copy the value of the name attribute, including "select_".
Add this code to your script to clear the values:
g_form.clearValue('<variable_name>');
g_form.clearOptions('select_0IO:71332c394e2ae212b8ec6f65f110c66e');//replace with your "select_" value
I believe the system technically recognizes the glide_list as two separate fields which is why both lines are necessary.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2017 01:44 PM
Hi Patrick,
did you finally get a way to set the glide_list value ? I'm stuck on the same.
Thanks
Agathe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 10:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2017 07:30 AM
Patrick-
I am also stuck on this for glide_lists
using the below code i was able to get my options to populate correctly returning from a glideAjax call UNTIL my onchange fired again (the user selected a different choice) So looking at your post I added the clear options you see in the second code snip. The weird part is that after adding the clear options I am only returning the last value in the string to the glide_list when the onChange fires. I am still returning all values in my xml response it is very unusual any thoughts?
var answer = response.responseXML.documentElement.getAttribute("answer");
var actionArray = answer.split(',');
for(i=0;i<actionArray.length;i++){
var ref = g_form.resolveNameMap('db_role');
$(ref + '_unlock').click();
addGlideListChoice('select_0' + ref, actionArray[i], actionArray[i]);
$(ref + '_lock').click();
}
var ref = g_form.resolveNameMap('db_role');
$(ref + '_unlock').click();
g_form.clearValue('db_role');
g_form.clearOptions('select_0IO:ba8c351fdb31f200ae7efdb61d96190c');
$(ref + '_lock').click();
$(ref + '_unlock').click();
addGlideListChoice('select_0' + ref, actionArray[i], actionArray[i]);
$(ref + '_lock').click();