How to get list collector values from custom table to catalog item variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2024 02:36 AM
Hi Team,
In custom table we have 2 fields
1.name
2.list collector referencing to user table
in catalog item
1.name
2.list collector- to user table
So, on change of name every time, the list collector should compare name with custom table and should dislay the names from custom list collector to variable list collector
Thanks,
Vinuthna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2024 08:00 AM
If the catalog item name variable is a reference to the custom table (where the name field is the display value) then you can start your onChange Catalog Client Script with a getReference to retrieve the value of the list collector field:
Otherwise, if you're just matching the name value in the variable to the same name value in the custom table you need to use Glide Ajax to do the lookup and return the value of the list collector field. This would work in the first scenario also
Once you have the value, via either method, which will be a comma-separated list of sys_ids from the sys_user table, you can simply use g_form.setValue to set the value of the list collector variable to the same names from the custom table, or if you are wanting to change the filter so that only these names are the ones available to be selected, then use this block of code:
var varName = 'v_users';// name of the list collector variable
var filterString = '';
//inside your GlideAjax or getReference callback function, set the answer or value = filterString variable, then
try{ //Service Portal method
var myListCollector = g_list.get(varName);
myListCollector.reset();
myListCollector.setQuery(filterString);
}
//Revert to Service Catalog method
catch(e){
window[varName + 'g_filter'].reset();
window[varName + 'g_filter'].setQuery(filterString);
window[varName + 'acRequest'](null);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2024 07:37 AM
Hi ,
I tried this code but it is not working can you please send me the script include demo code once .
Thanks,
Vinuthna