- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 07:27 AM
client script written onchange of - account owner variable - list collector
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue == '') {
var myListCollector = g_list.get('ten_cloud_account_name');
myListCollector.reset();
}
var ga = new GlideAjax('UtilsAjax');
ga.addParam('sysparm_name', 'isPrimaryOwner');
ga.addParam('sysparm_account_owner', newValue);
ga.getXMLAnswer(function(response) {
var count = parseInt(response);
if (count <= 0) {
g_form.clearValue('ten_cloud_account_owner');
g_form.showFieldMsg('ten_cloud_account_owner', 'Please select the proper cloud account owner.', 'error');
} else {
populateCloudAccounts(newValue);
}
});
function populateCloudAccounts(ownerId) {
var ga = new GlideAjax('UtilsAjax');
ga.addParam('sysparm_name', 'getCloudAccountsByOwner');
ga.addParam('sysparm_account_owner', ownerId);
ga.getXMLAnswer(function(response) {
if (newValue != '') {
var listCollector = g_list.get('ten_cloud_account_name');
if (listCollector) {
listCollector.reset();
listCollector.setQuery(response + '^nameISNOTEMPTY');
}
} else {
g_form.clearValue('ten_cloud_account_name');
}
});
}
}
client script written omchange of cloud account name variable list collector
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue != '') {
var ga = new GlideAjax('UtilsAjax');
ga.addParam('sysparm_name', 'populateOwner');
ga.addParam('sysparm_cloudid', newValue);
ga.getXMLAnswer(function(response) {
var ans = response;
g_form.setValue('ten_cloud_account_owner', ans);
g_form.setReadOnly('ten_cloud_account_owner');
});
}
}
now what I am doing is when an user selects primary account owner from the variable the respective cloud accounts will be filtered in the list
if the user don't know primary owner then he can select the account from cloud account name list collector then the primary owner is auto populated
if I wanted to select multiple cloud accounts its not allowing me to select its clearing the values in the list
What to do now - suggest any other way or how can I approach now
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 10:52 PM
Response to your 1st part below - filtering list collector based on 1st reference variable
then you should use advanced reference qualifier on list collector to show accounts under that person
Something like this
javascript:'ownerField=' + current.variables.firstVariableName;
Also give this in variable attributes
ref_qual_elements=firstVariableName
I didn't get this part -> I dont know account owner If I select the account from list collector it will auto npopulate that owner and the list will only show his accounts -> since 2nd variable will be filtered based on 1st, if 1st itself is empty how 2nd will be filtered. Also 2nd variable is list collector and user can select multiple accounts then which account owner will you populate in the 1st variable
I believe you should discuss the 2nd requirement with your customer.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 08:07 AM
I'm not seeing the populateOwner function. If it is working when you select one cloud account in the list collector, but not when you are selecting multiple values, you may just need to change the GlideRecord in the function to accommodate the value passed in from the client being a comma-separated list of sysids.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 08:42 AM
This is written in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 08:48 AM
sorry what's your actual business requirement
you have a list collector and based on change of that what you wish to do?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2025 09:03 AM
If I select account owner list should only show his accounts and if I select cloud account owner should auto populate now If I select multiple accounts of same owner I couldnt able to do that