Fetching catalog checkbox variable value in its client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2014 03:47 AM
Hi
I have 4 check box variables in my catalog.I want to make a client script so that on submit at least one variable should be checked among those 4 variables.
I am trying with an onSubmit catalog client script..to test what it returns I tried something like this for one variable:
function onSubmit()
{
var temp1= g_form.getValue('checkbox_var1');
if(!temp1) //assumed it will return true as I have not check the variable on the form
{
alert('Please check the field checkbox_var1');
return false;
}
}
But I am not getting the popup as expected.Any suggestion where am going wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2014 12:08 PM
Pradeep Sharma Thanks for the help ...working fine now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2014 06:18 AM
Hello Sitarani,
As mentioned in the ServiceNow Guru site, we can force the user to select atleast one of the checkboxes using client script. Another approach to do so would be UI Policy.
For e.g.
If there are 3 checkboxes "cb1,cb2 and cb3" and label used to group the checkboxes is "Select any one", you can write a UI Policy (reverse if false) with the condition as
if cb1 is not true, and
cb2 is not true, and
cb3 is not true
then make label "Select any one" as mandatory.
This should work well for countable number of checkboxes.
Regards,
Probir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2014 12:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2015 07:37 AM
Make sure to mark this discussion as answered.
