Variable set Mandatory!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 04:56 AM
Hi Team,
We have more that 60 variables in the variable set .we need to make these variables mandatory in a catalog item.
I am trying to make a variable set mandatory but Not working,Is it possible to make the entire variable set mandatory.
script
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setMandatory('ServerType2',true); //variable set name: ServerType2
}
Working for dispaly
g_form.setDisplay(' ServerType2',true);
Regards,
Ajay.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 05:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 05:05 AM
Hi Ajay
Unfortunately you need to set each variable mandatory.
Maybe you can create some async Ajax call to recall the variable set, store all the variables into an array and than using the array make them mandatory
Cheers
R0b0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 05:07 AM
Dear Ajay,
I second with the approach that R0b0 suggested. Let us know if u need help with scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 05:45 AM
Hi Ajay,
One thing you can do is query the "item_option_new" table with the variable set sys_id and get all the variable names. iterate over this and make those as mandatory.
var gr = new GlideRecord('item_option_new');
gr.addQuery('variable_set','034b5e724f832200fc11fa218110c73a'); // sys_id of the variable set
gr.query();
while(gr.next()){
g_form.setMandatory(gr.name,true);
}
If you want to optimize that then have GlideAjax and return an array of variable names from script include and then iterate that array in client script and then make it as mandatory true.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader