- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2024 03:28 AM
Hi Everyone.. Iam stuck with an OnChange client script that goes nowhere . The requirement is
There is a checkbox variable on a catalog form called Access
when it is checked true, I am trying to add two specific users in a list collector variable called Managers
They are static values and hence Im using sys IDs of both users in the client script.
Can someone please help me with code snippet that will work both in service catalog and servuce portal. I tried with addOptions removeOptions and that doesn’t seem to be working on portal returns Javascript error.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 01:56 AM
Hi @SanaPR ,
Try the below in onChange client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'true') {
var usersList = '4ae3ab0753101200ed11da86a11c0881,3f0370019f22120047a2d126c42e705e';
g_form.setValue('managers', usersList.toString());
}
}
Result:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2024 03:57 AM - edited 07-27-2024 04:21 AM
Hi @SanaPR ,
Please check the below article, it will fulfill your requirement:
Dynamically set list collector on change of variable
Setting List collector values in Service Portal by catalog client script
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 12:54 AM
Hi , I referred the above article. This has a script include for dynamic list collector variables. For me I have static users that can be mentioned in the client script with sys IDs. Is there a way to achieve this without using script include?
thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 01:56 AM
Hi @SanaPR ,
Try the below in onChange client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'true') {
var usersList = '4ae3ab0753101200ed11da86a11c0881,3f0370019f22120047a2d126c42e705e';
g_form.setValue('managers', usersList.toString());
}
}
Result:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 03:59 AM
This worked except userList var needed to be an array. Here’s the exact ode that worked for me.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'true') {
var userList = ['77a8969c87e3515068ac2f88dabb35cb','29da121c87ef1110d359bae6dabb3583'];
g_form.setValue('managers’, userList.join(','));
}
else {
g_form.clearValue('managers’);
}
}
Thank you for all the help!