- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
In ServiceNow using the list collector was tricky and helpful where we can able to perform/request more values in a single request
Let’s understand the list collector functionality
Selection of Multiple Items: Users can select multiple items from a list presented in the catalog item form. This is particularly useful when users need to choose multiple related options or entities, such as software applications, services, asset or group.
Benefits:
- User Experience: Simplifies the selection process for users needing multiple items.
- Efficiency: Reduces the need for multiple catalog items by allowing consolidated selections.
- Flexibility: Supports dynamic and conditional item selections based on various criteria.
Let’s understand with a simple use case
Example: User need to be removed from the group he/she present (looks simple ryt )
NOTE: Auto populate the groups based on the user they have selected customer wants to have the auto population of group on the list collector
Script include:
var Populategroup = Class.create();
Populategroup.prototype = Object.extendsObject(AbstractAjaxProcessor, {
userDetails: function() {
var sys_id = [];
var user = this.getParameter("sysparm_user");
var userList = new GlideRecord("sys_user_grmember");
userList.addQuery("user", user);
userList.query();
while (userList.next()) {
var group = userList.group.sys_id.toString();
var grp = new GlideRecord("sys_user_group");
grp.get("sys_id", group);
if (grp.sys_id) {
sys_id.push(group);
}
}
return sys_id.toString();
},
type: 'Populategroup'
});
Client Script: Populate group based on user selected
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var user = g_form.getValue("requested_for");
var ga = new GlideAjax('Populategroup'); // Populategroup is the script include class
ga.addParam('sysparm_name', 'userDetails'); // userDetails is the script include fucntion method
ga.addParam('sysparm_user', user); // Set parameter sysparm_user to 'user'
ga.getXML(userPopulate);
// the callback function for returning the result from the server-side code
function userPopulate(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue("list_of_groups", answer);
}
Result:
Thanks and Regards,
Srikanth
LinkedIn: https://www.linkedin.com/in/perumandla-srikanth/
Wondering will it work on the native as well
Result on the Native:
Happy Learning😉
- 624 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.