- 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 09:06 AM
update script include as this so that it queries and pushes all the owners and then return and set the values
populateOwner: function() {
var arr = [];
var id = this.getParameter('sysparm_cloudid');
var gr = new GlideRecord('table -name');
gr.addQuery('sys_id', 'IN', id);
gr.query();
while (gr.next()) {
arr.push(gr.u_account_owner.toString());
}
return arr.toString();
},
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:25 AM
No need of multiple owners if cloud account is selected it will automatically autopopulate owner and when owner is filled it will filter only his account
problem is if i try to select his second account the value is getting cleared
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2025 10:03 AM
sorry your requirement is not clear.
please share some screenshots of your catalog form and your variable configuration screenshots.
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 10:43 PM
2 Variables one is reference and another is list collector If I select reference variable the list will filter the accounts under him and if 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
- 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