- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2019 11:25 AM
Hello,
I have requirements to automatically populate Service Portal Catalog Item List Collector variable based on Select Box variable entry.
I created relationship table u_teammate_position_profiles between Teammate Position and Teammate Profile
Position = u_position
Profile = u_profile
I was able to dynamically short list Teammate Position Roles (referenced to Profile) based on the selected Teammate Position (reference Position)
Manually selecting the Profiles (Roles)
The requirement is to automatically populate the List Collector Teammate Position Roles (teammate_position_roles) based on the selected Position. I know client script and script include probably the best method to implement but it is not working for me so far.
Assistance is greatly appreciated
Regards,
Mike
Solved! Go to Solution.
- Labels:
-
Request Management
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2019 03:04 PM
Below blog explains how to auto populate list collector in Portal
https://community.servicenow.com/community?id=community_blog&sys_id=571da2e5dbd0dbc01dcaf3231f961913

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2019 03:04 PM
Below blog explains how to auto populate list collector in Portal
https://community.servicenow.com/community?id=community_blog&sys_id=571da2e5dbd0dbc01dcaf3231f961913
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 04:55 AM
Hi Dvp,
I have a similar requirement and i followed the same step exactly but am not able to get the same results. So basically i have one refernce variable Of Group table and another List collector Variable of User type. so whenever i select a group which has a field as "Ownership" and wen the ownership value is Customer.. i want to show only those list of user records which contains a particular phrase in their email id.
Client Script
-----------------------------------------
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
//g_form.setReadOnly('name',true);
var ga = new GlideAjax("test");
ga.addParam("sysparm_name","getUserDetails");
ga.addParam("sysparm_id",newValue);
//alert(newValue)
ga.getXML(setManager);
function setManager(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
//gs.log("inclient"+answer);
alert('hello')
alert(answer)----->getting all the required value upto here
//addition
var arr = answer.split('||');
//arr[1] has the sys_id of the users
//arr[0] has the display name of the users
if (window === null)
g_form.setValue('add_group_members', arr[1], arr[0]);
else
addItemstoList('add_group_members', arr[1], arr[0]);
}
function addItemstoList(listCollector, sysid, display_value) {
var varName = listCollector;
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
var selectedOptionsIDs = [];
rightBucket.options.length = 0;
if (sysid != '') {
var myCIArray = sysid.split(',');
var displayvalue = display_value.split(',');
for(i=0; i < myCIArray.length; i++) {
var option = document.createElement('option');
option.value = myCIArray[i];
option.text = displayvalue[i];
// add the option to the bucket
rightBucket.add(option);
}
}
// sort the buckets
sortSelect(rightBucket);
moveSelectedOptions(selectedOptionsIDs, leftBucket, rightBucket, '--None--');
}
}
Script Include
-------------------------------------------------
var test = Class.create();
test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserDetails:function(name){
// var answer=[];
var name_arr = [];
var sys_id_arr = [];
var userSysId = this.getParameter('sysparm_id');
var ga;
var gr = new GlideRecord("sys_user_group");
if(gr.get(userSysId))
{
gs.log('test1' +gr.u_ownership);
if(gr.u_ownership=="Customer")
{
gs.log('test2');
ga= new GlideRecord('sys_user');
ga.addEncodedQuery('emailLIKEaxisys');
ga.query();
while(ga.next())
{
//gs.log('users are'+answ er.push(ga.sys_id)) ;
name_arr.push(ga.name.toString());
sys_id_arr.push(ga.sys_id.toString);
}
}
}
gs.log('users are'+name_arr.length) ;
gs.log('object of user'+name_arr) ;
gs.log('sysid of user'+sys_id_arr) ;
// return sys_id_arr;
return name_arr.toString() + '||' + sys_id_arr.toString(); ----------> checked and it returns the desired result
}
});
My only issue is the list value is not getting pushed to that list collector variable in Portal.
Can you please let me know what wrong am doing.
For your ref we are working in London version
Thanks,,,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2019 06:22 AM