- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 04:04 AM
Hi,
We have a catalog item "Access" and it has a variable called 'Category' select box type. It has couple of choices instead of 'None' we want to use "--Please select a value--" option. I have created onload script and it is working in native view but portal not setting the value.Please check attached screenshots.
Onload Native view
onload service portal - by default it is setting to first choice option instead of '"--Please select a value--"
can anyone suggest me to resolve this issue?
Thanks,
Rakesh T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 05:08 AM
Hi @Rakesh50
Try this code
g_form.removeOption('category','');
g_form.addOption('category','', '--Please select a value--', 0); //no spaces for second paramter
g_form.setMandatory('category', true);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 04:41 AM
Make sure you check Include None to true and use below code:
g_form.removeOption('category','');
g_form.addOption('category', ' ', '--Please select a value--', 0);
g_form.setMandatory('category', true);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 04:49 AM
Now it is working for service portal but not in platform view. It is setting to choice option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 05:08 AM
Hi @Rakesh50
Try this code
g_form.removeOption('category','');
g_form.addOption('category','', '--Please select a value--', 0); //no spaces for second paramter
g_form.setMandatory('category', true);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 04:45 AM
What about using a default value --Please select a value-- mention it while creating the variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-10-2023 05:19 AM
hi @Anubhav24 ,
if we can set default value then mandatory is not applying to the field.