- 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-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-24-2022 01:26 AM
Thanks Ankur. It worked perfectly for Catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2022 01:29 AM
Glad to know.
Please mark response helpful.
Also mark blog as helpful and bookmark it if that helped.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader