- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2014 02:35 AM
We have an order guide that contains a series of variables for user information and then lists a series of accounts the user can request.
As things stand if the user doesn't choose an account and then selects the 'Choose Options' button it falls over so I need to find a way to force the user to select at least one of these accounts before they can select 'Choose Options'.
Any input gratefully received.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2015 06:23 AM
Your 'onSubmit' client script should be against the catalog item (the actual item/order guide), not on the Order Guide table. Use the 'Client Scripts' related list at the bottom of your order guide form to add the necessary catalog client script. If the related list isn't there, you'll need to personalize related lists to add it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2014 04:07 AM
Trouble is there are multiple accounts/order items and if none are selected I need to force the user to select one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2015 04:19 AM
This SNGuru article may help...
http://www.servicenowguru.com/scripting/client-scripts-scripting/checkbox-variables-mandatory/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2015 06:19 AM
Mark, thanks for reading. I've tried having a go at your suggestion by creating an onSubmit client script on the Order Guide table as below and it doesn't work, any thoughts?
function onSubmit(){
//Set the mandatory checkbox variable names and total mandatory count here
var mandatoryVars = 'vision,u_other_amendments,trf,tms,pkms,opus,e400,coda,adaccount,ace';
var mandatoryCount = 1;
var passed = forceMandatoryCheckboxes(mandatoryVars, mandatoryCount);
if(!passed){
//Abort the submit
alert('You must select at least ' + mandatoryCount + ' options.');
return false;
}
}
function forceMandatoryCheckboxes(mandatory, count){
//Split the mandatory variable names into an array
mandatory = mandatory.split(',');
var answer = false;
var varFound = false;
var numTrue = 0;
//Check each variable in the array
for(x=0;x<mandatory.length;x++){
//Check to see if variable exists
if(g_form.getControl(mandatory[x])){
varFound = true;
//Check to see if variable is set to 'true'
if(g_form.getValue(mandatory[x]) == 'true'){
numTrue ++;
//Exit the loop if we have reached required number of 'true'
if(numTrue >= count){
answer = true;
break;
}
}
}
}
//If we didn't find any of the variables allow the submit
if(varFound == false){
answer = true;
}
//Return true or false
return answer;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2015 06:23 AM
Your 'onSubmit' client script should be against the catalog item (the actual item/order guide), not on the Order Guide table. Use the 'Client Scripts' related list at the bottom of your order guide form to add the necessary catalog client script. If the related list isn't there, you'll need to personalize related lists to add it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2015 06:33 AM
Perfect Mark, thank you so much.