Not able to hide the variable set of a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 07:12 AM
Hi Im trying to hide my variable set Create new group based on the selection of the request type:
Using the following code:
function onChange(control, oldValue, newValue, isLoading) {
// if (isLoading || newValue == '') {
// return;
// }
var type = g_form.getValue('request_type');
if(type=='create'){
//g_form.addInfoMessage('test '+type);
g_form.setVisible('Create_New_Group',false);
g_form.setDisplay('Create_New_Group',false);
g_form.setVisible('create_new_group',false);
g_form.setDisplay('create_new_group',false);
}
//Type appropriate comment here, and begin script below
}
But it is no hiding the variable set, I've also checked there are no containers in the variable set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 07:43 AM
Hi @aditya174 ,
I have answered this question under https://www.servicenow.com/community/developer-forum/not-able-to-hide-the-variable-set-of-a-catalog-...
Let me know that is working as expected.
Thanks,
pradeep[
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2024 09:41 AM
Hello @aditya174
I have found the mistake, replace variable set name with the variable name. You need to mention each variable that has to be variable set to false.
g_form.setDisplay('Create_New_Group',false); //replace variable set name with variable name in variable set
replace with:
g_form.setDisplay('group_name',false); //group_name is the variable name in variable set
Here are the screenshots from my PDI:
Catalog Client script:
Updated script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var type = g_form.getValue('request_type');
if (type == 'create') {
g_form.setVisible('group1', false);//group1 is the variable name in variable set
//similarly add other variables
} else {
g_form.setVisible('group1', true); //To show back the variable when type is not 'create'
//similarly add other variables
}
}
Variable in variable set:
Result:
when request type is not create
when request type is create
Note: type == 'create', here 'create' is the value assign to the choice Create
"If you found my answer helpful, please like and mark it as the "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar