Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 06:55 AM
Hi @Rohit Singh ,
Create a Script Include:
Make sure the Client Callable checkbox is checked.
use below code for the Script Include:
var FilterUsersByCompany = Class.create();
FilterUsersByCompany.prototype = {
initialize: function() {
},
getUsersByCompany: function(companySysId) {
var users = [];
var userGR = new GlideRecord('sys_user');
userGR.addQuery('company', companySysId);
userGR.query();
while (userGR.next()) {
users.push(userGR.getUniqueValue());
}
return users.join(',');
},
type: 'FilterUsersByCompany'
};
Use the Script Include in the Advanced Reference Qualifier of your second variable:
Go to your Service Catalog item and open the second variable (List Collector).
In the Advanced Reference Qualifier section, select Dynamic and then choose Advanced.
Use the following code in the Reference qualifier script:
var companySysId = current.variables.first_variable_name; // Replace 'first_variable_name' with the actual name of your first variable
var filter = new FilterUsersByCompany();
answer = 'sys_idIN' + filter.getUsersByCompany(companySysId);
If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar