- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 03:00 AM
I am trying to populate value in right slush bucket on the basis of results from Script include.
It populates the right slush bucket as expected. But when I submit the form, it shows mandatory field error for this List collector variable. However, it already has values populated from script include results. After just clicking any value on right slush bucket , it allows to submit. Not able to understand the reason.
Below are the codes :
SCRIPT INCLUDE
getParticipants: function() {
var part = '';
var participants = this.getParameter('sysparm_participants');
var loc1 = new GlideRecord('sys_user');
loc1.addQuery('sys_id', 'IN', participants);
loc1.query();
while (loc1.next()) {
if (part == '')
part = loc1.sys_id + '**' + loc1.name;
else {
part = part + ',' + loc1.sys_id + '**' + loc1.name;
}
}
gs.log("Part--"+part,'GlideRidac');
return part;
},
CLIENT SCRIPT (onChange of a variable)
addClassroomParticipants('u_classroom_participants', values[23]); //values[23] has sys_ids of user (comma separated)
function addClassroomParticipants(varname, participants) {
var varName = varname;
var participnts = participants;
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
var ga = new GlideAjax('GlideRecordRidac');
ga.addParam('sysparm_name', 'getParticipants');
ga.addParam('sysparm_participants', participants);
ga.getXML(setUserData);
function setUserData(response) {
var answer = response.responseXML.documentElement.getAttribute("answer").split(",");
for (var i = 0; i < answer.length; i++) {
var loc1 = answer[i].split('**');
var option = document.createElement("option");
option.value = loc1[0].toString(); //loc1.sys_id;
option.text = loc1[1]; //loc1.name;
rightBucket.add(option);
}
}
moveSelectedOptions('', leftBucket, rightBucket, '--None--');
sortSelect(leftBucket);
//sortSelect(rightBucket);
}
Please let me know if anyone has solution for it.
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2022 01:30 AM
check my blog on how to set list collector based on other variable
try to use that script
If my blog helps please mark it helpful and also bookmark it
Dynamically set list collector on change of variable
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 03:19 AM
Hello
At the end why is it showing sortSelect(rightBucket) commented out.
It sould be tge one in the code and comment out sortSelect(leftBucket)
Please mark answer correct/helpful based on impact Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 04:41 AM
Hi Saurav,
Tried after doing this change, values are autopopulated as earlier but still it is not allowing to submit and shows List collector field mandatory error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2022 04:47 AM
Hello
You can check the below thread you may find your answer
https://community.servicenow.com/community?id=community_question&sys_id=76bd3cd6dbff58d0fb115583ca961986
Please mark answer correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2022 01:21 AM
Hi Saurav,
I tried after doing changes, still the same issue is coming.