- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2016 07:44 PM
Folks, I have checked almost all the options for having another data type but looks like 'list collector' is the only available data type for selecting multiple values. But my requirement is there are 2 'list collector' variables and with this data type you can only select 1 variable. If you select another the previous one gets over-written. Something like this below:
Now, if I want to order 2 VAR 1's in the same SCREQ, it wouldn't allow as the VAR 1 variable only stores the most recent selection. Is there any way to overcome this as this seems to be a very critical requirement and using check-boxes doesn't seem like the best possible option as there are 64 records in the table that VAR 1 is referencing.
Thanks in advance !!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2016 04:03 AM
Try this 😃
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
//Name of the list collector that the filter shall apply on
var collectorName = 'users';
//If the newValue isn't empty, build the filter
if( newValue != '') {
//Lets split up the string into an array
var answer = newValue.split(',');
var filterString = [];
//First filter shouldnt start with an "or" so lets set it here with the first value
filterString = 'department=' + answer[0];
//If there is selected more than one department, put those in as "OR" conditions
if(answer.length > 1){
for (var i=1; i<answer.length;i++){
filterString += '^ORdepartment=' + answer[i];
}
}
eval(collectorName + 'g_filter.reset()');
eval(collectorName + 'g_filter.setQuery("' + filterString + '")');
eval(collectorName + 'acRequest(null)');
}
//If the newValue is empty, just reset the filter
else{
eval(collectorName + 'g_filter.reset()');
eval(collectorName + 'acRequest(null)');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2016 07:50 PM
Hi Suhas,
You should be able to have two different list collector variables on your form, just make sure the variables are named differently.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2016 08:28 PM
Thanks mate, I am almost there. I changed the VAR 1 to a list collector & now there are 2 list collector variables on the catalog item. But the issue now is the VAR 2 variable value is not changing depending on VAR 1 value.
This is the existing VAR 2 variable attributes - 'ref_auto_completer=AJAXTableCompleter,ref_ac_display_value=u_role,ref_ac_columns=u_role,ref_ac_order_by=u_database_name'. Not sure what this means on this list collector & this is how the VAR 2 has its filter auto populated :
I need the VAR 2 filter to be showing the exact value that was selected in VAR 1 and show the updated values in its list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2016 10:05 PM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Set the list collector name
var collectorName = 'database_role',
flag = true,
filterString = 'u_application_name=' + g_form.getValue('application_name') + '^u_database_name=' + g_form.getValue('database_name') + ''; // Create a filter to the be applied to the list collector variable
if (g_form.getTableName() == "sc_req_item" || g_form.getTableName() == "sc_task")
flag = false;
if (flag === true) {
if (newValue == '') { // If the form is loading or we have a blank newValue
g_form.setMandatory(collectorName, false); // Set mandatory to false
g_form.setDisplay(collectorName, false); // Hide the list collector
return; // Return, stop processing further
}
}
// Find the filter elements
/*
var fil = gel('ep');
//Hide the filter elements
fil.rows[0].style.display = 'none'; // Hide the search
fil.rows[1].style.display = 'none'; // Hide the filter buttons
fil.nextSibling.rows[0].style.display = 'none'; // Filter description text
fil.nextSibling.nextSibling.style.display = 'none'; // Hide the description below the slushbucket
*/
// Clear right bucket only if this is not an sc_req_item or sc_task form
if (flag === true) {
var rightBucket = gel(collectorName + '_select_1');
var selectedOptions = rightBucket.options;
for (var i = selectedOptions.length - 1; i > -1; i--)
rightBucket.remove(selectedOptions[i]); // Remove value
}
// Reset the filter query
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(filterString);
window[collectorName + 'acRequest'](null);
if (flag === true) {
window.setTimeout(function() {
g_form.setDisplay(collectorName, true); // Redisplay the list collector variable
g_form.setMandatory(collectorName, true); // Set the list collector variable to mandatory
}, 1000);
}
}
This is the catalog client script currently running, but this was for the previously used 'Reference' data type on VAR 1. When I changed it to a list collector, the first selection works fine on VAR 2, but the subsequent selections just show the sysID and nothing in that list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 05:45 AM
Hi Suhas,
The value of the first list collector will be a comma separated list of sys_ids if there are more than one, so you would need to do something like u_database_nameIN or something like that.