How to select multiple options in a list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
My requirement is to have ability to select multiple options in a List of SIDs affected variable. Currently I am able to select only one value at a time. Kindly help.
Regards
Suman P.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) {
return;
}
var ga = new GlideAjax('GetSIDsBySite');
ga.addParam('sysparm_name', 'getSIDs');
ga.addParam('sysparm_site', newValue);
ga.getXMLAnswer(function(response) {
if (response && response.trim() !== '') {
g_form.setValue('u_list_of_customers_affected', response);
} else {
g_form.clearValue('u_list_of_customers_affected');
}
});
}
var GetSIDsBySite = Class.create();
GetSIDsBySite.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSIDs: function() {
var site = this.getParameter('sysparm_site');
if (!site) {
return '';
}
var sidList = [];
var gr = new GlideRecord('sn_install_base_sold_product');
gr.addQuery('u_location', 'IN', site);
gr.query();
while (gr.next()) {
sidList.push(gr.getUniqueValue());
}
return sidList.join(',');
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
function onChange(control, oldValue, newValue, isLoading) {
// Do nothing on form load
if (isLoading) {
return;
}
// If Site is cleared → clear SIDs
if (!newValue) {
g_form.clearValue('u_list_of_customers_affected');
return;
}
// Call Script Include to fetch SIDs
var ga = new GlideAjax('GetSIDsBySite');
ga.addParam('sysparm_name', 'getSIDs');
ga.addParam('sysparm_site', newValue);
ga.getXMLAnswer(function(response) {
if (response && response.trim() !== '') {
g_form.setValue('u_list_of_customers_affected', response);
} else {
g_form.clearValue('u_list_of_customers_affected');
}
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
var site = g_form.getValue('u_location');
var serviceType = g_form.getValue('u_service_type');
// ❌ If Site OR Service Type is empty → clear SIDs
if (!site || !serviceType) {
g_form.clearValue('u_list_of_customers_affected');
return;
}
// ✅ Call Script Include
var ga = new GlideAjax('GetSIDsByFilter');
ga.addParam('sysparm_name', 'getSIDs');
ga.addParam('sysparm_site', site);
ga.addParam('sysparm_service_type', serviceType);
ga.getXMLAnswer(function(response) {
g_form.setValue('u_list_of_customers_affected', response);
});
}
var GetSIDsByFilter = Class.create();
GetSIDsByFilter.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getSIDs: function() {
var site = this.getParameter('sysparm_site');
var serviceType = this.getParameter('sysparm_service_type');
var sidList = [];
var gr = new GlideRecord('sn_install_base_sold_product');
// ✅ Filter by Site
gr.addQuery('u_location', 'IN', site);
// ✅ Filter by Service Type (product)
gr.addQuery('product', serviceType);
gr.query();
while (gr.next()) {
sidList.push(gr.getUniqueValue());
}
// 🔥 Important: return comma-separated sys_ids
return sidList.join(',');
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
javascript: (function() {
var gr = new GlideRecord('sn_install_base_sold_product');
gr.addQuery('u_location', current.u_location);
gr.query();
var ids = [];
while (gr.next()) {
ids.push(gr.product.toString());
}
return 'sys_idIN' + ids.join(',');
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
javascript: (function() {
if (!current.u_location)
return 'sys_id=-1';
var gr = new GlideRecord('sn_install_base_sold_product');
gr.addQuery('u_location', current.u_location);
gr.query();
var ids = [];
while (gr.next()) {
ids.push(gr.product.toString());
}
if (ids.length == 0)
return 'sys_id=-1';
return 'sys_idIN' + ids.join(',');
})();