- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:41 AM
Hi All,
I have the below client script to move list collector values from left to right. It is working in the portal but in the native UI the filter is not working, it is transferring everything from left to right. Could someone please check and let me know how to fix it.
Thanks in advance.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearValue('sftp_sites_to_update');
if (newValue !== '') {
var parm = '';
if (window === null)
parm = 'portal';
else
parm = 'native';
}
var accntsList = 'sftp_sites_to_update'; // variable name of the List Collector
var filterString = 'u_active=true^owned_by=' + newValue;
alert('filterString - ' + filterString);
// filter list collector to only show the accounts owned by the current user (left side)
// reset the filter (left side) based on the above filterstring
if (parm == 'portal') {
var myListCollector = g_list.get(accntsList);
myListCollector.reset();
myListCollector.setQuery(filterString);
g_form.hideFieldMsg('sftp_current_owner', true);
g_form.showFieldMsg('sftp_current_owner', 'Please wait... searching for SFTP Account(s)...');
} else {
window[accntsList + 'g_filter'].reset();
window[accntsList + 'g_filter'].setQuery(filterString);
window[accntsList + 'acRequest'](null);
g_form.hideFieldMsg('sftp_current_owner', true);
g_form.showFieldMsg('sftp_current_owner', 'Please wait... searching for SFTP Account(s)...');
}
//now populate the Service Portal variable
if (parm == 'portal') {
var ajax = new GlideAjax('SFTPutil');
ajax.addParam('sysparm_name', 'getSFTP_Accnts');
ajax.addParam('sysparm_owner', newValue);
ajax.getXML(populateValues);
} else {
var leftBucket = gel(accntsList + '_select_0');
var rightBucket = gel(accntsList + '_select_1');
var selectedOptions = leftBucket.options;
//Get an array of all option IDs to move
var selectedIDs = new Array();
alert('selectedIDs ' + selectedIDs);
var index = 0;
for (var i = 0; i < selectedOptions.length; i++) {
selectedIDs[index] = i;
index++;
}
rightBucket.options.length = '0';
moveSelectedOptions(selectedIDs, leftBucket, rightBucket);
sortSelect(rightBucket);
g_form.hideFieldMsg('sftp_current_owner', true);
if (selectedIDs == 0) {
g_form.showFieldMsg('sftp_current_owner', 'No SFTP Account(s) found!');
}
}
function populateValues(response) {
g_form.hideFieldMsg('sftp_current_owner', true);
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert('answer = ' + answer);
if (answer == '||') {
g_form.showFieldMsg('sftp_current_owner', 'No SFTP Account(s) found!');
}
var arr = answer.split('||');
//arr[1] has the sys_id of the accountID
//arr[0] has the display name of the accountID
g_form.setValue('sftp_sites_to_update', arr[1], arr[0]);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:57 AM
Hi,
you can refer below blog for help for similar requirement
https://community.servicenow.com/community?id=community_blog&sys_id=a60c397edb04dc1c190dfb24399619b1
Client Script: Ensure "Isolate Script" field is set to false for onChange Catalog Client Script on that Variable
- The field Isolate Script is not present on the form view
- From the list layout it can be added and set to false
- By default it is true
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:48 AM
just confirming, did you set "Isolate Script" field to false in your client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2020 05:57 AM
Hi,
you can refer below blog for help for similar requirement
https://community.servicenow.com/community?id=community_blog&sys_id=a60c397edb04dc1c190dfb24399619b1
Client Script: Ensure "Isolate Script" field is set to false for onChange Catalog Client Script on that Variable
- The field Isolate Script is not present on the form view
- From the list layout it can be added and set to false
- By default it is true
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 01:49 PM
Thanks Ankur!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2020 01:51 PM
may i know what was the issue, so it will be helpful for other user who will see this thread in future.