- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2015 02:08 PM
Good evening all.
One of our field values 'Domain' has the option of 'Cross-domain' - if this value is chosen various checkboxes with different values appear. One of these check-box options is 'Global' - which when checked means all options (domains) are checked automatically. This is done via an onChange client script which is working fine:
function onChange(control, oldValue, newValue) {
var global = g_form.getValue('u_member_firm_impacted_global');
if (global == 'true') {
g_form.setValue('u_member_firm_impacted_nrfa', 'true');
g_form.setValue('u_member_firm_impacted_nrfcan', 'true');
g_form.setValue('u_member_firm_impacted_nrfllp', 'true');
g_form.setValue('u_member_firm_impacted_nrfsa', 'true');
g_form.setValue('u_member_firm_impacted_nrfus', 'true');
}}
There is currently another onChange another client script which exists to deselect the checkboxes if 'Global' is unchecked:
function onChange(control, oldValue, newValue) {
var global = g_form.getValue('u_member_firm_impacted_global');
if (global == 'false') {
g_form.setValue('u_member_firm_impacted_nrfa', 'false');
g_form.setValue('u_member_firm_impacted_nrfcan', 'false');
g_form.setValue('u_member_firm_impacted_nrfllp', 'false');
g_form.setValue('u_member_firm_impacted_nrfsa', 'false');
g_form.setValue('u_member_firm_impacted_nrfus', 'false');
}}
Again this works in the unselect behaviour but the issue is that if 'Global' is not the checkbox checked and any others are e.g. NRFA and NRFCAN then on update of the record, these values are not saved as of course the above script is saying to blank out all values if 'Global' is false.
Any help on how best to solve this problem sincerely appreciated. I can obviously make the above client script inactive but it would be nice to have the option if Global is unticked to deselect all the checkboxes.
On a different note, if anyone knows how I can reduce the height of the 'Please select all regions....' message that would be a lovely bonus!
Thank-you!
Daniel
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2015 11:50 PM
I would create a function as below for the simplicity of code maintenance. If you want to change fields in future, you will just need to edit the array and the code will still continue to work
function selectUnselectFields(fieldName,display)
{
var fieldsArray=fieldName.toString().split(',');
var stringResult='';
for(var i=0;i<fieldsArray.length;i++)
{
stringResult += "g_form.setValue(\""+ fieldsArray[i] + "\","+display+");";
}
eval(stringResult);
}
function onLoad() {
var fieldName=["u_check_1","u_check_2","u_check_3"];
selectUnselectFields(fieldName,true);
}
Once the function is defined, you can create a onchange client script and call the above function with the field names and a parameter to denote if the checkboxes need to be selected or unselected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2015 04:11 AM
just try to replace true/false object with string('true' / 'false') in there. and it should work fine.
function onChange(control, oldValue, newValue){
if (newValue == 'true') {
g_form.setValue('u_member_firm_impacted_nrfa', 'true');
g_form.setValue('u_member_firm_impacted_nrfcan', 'true');
g_form.setValue('u_member_firm_impacted_nrfllp', 'true');
g_form.setValue('u_member_firm_impacted_nrfsa', 'true');
g_form.setValue('u_member_firm_impacted_nrfus', 'true');
}
else{
g_form.setValue('u_member_firm_impacted_nrfa', 'false');
g_form.setValue('u_member_firm_impacted_nrfcan', 'false');
g_form.setValue('u_member_firm_impacted_nrfllp', 'false');
g_form.setValue('u_member_firm_impacted_nrfsa', 'false');
g_form.setValue('u_member_firm_impacted_nrfus', 'false');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2015 04:38 AM
Sorry Gurpreet but what exactly am I swapping out in the above example? I think I need more coffee!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2015 03:32 AM
Thank-you for this Steven - the only issue I am finding is again the prompt '"Would you like to uncheck all of the fields?"' is appearing on form load regardless of whether the 'Global' checkbox has been ticked?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2015 11:50 PM
I would create a function as below for the simplicity of code maintenance. If you want to change fields in future, you will just need to edit the array and the code will still continue to work
function selectUnselectFields(fieldName,display)
{
var fieldsArray=fieldName.toString().split(',');
var stringResult='';
for(var i=0;i<fieldsArray.length;i++)
{
stringResult += "g_form.setValue(\""+ fieldsArray[i] + "\","+display+");";
}
eval(stringResult);
}
function onLoad() {
var fieldName=["u_check_1","u_check_2","u_check_3"];
selectUnselectFields(fieldName,true);
}
Once the function is defined, you can create a onchange client script and call the above function with the field names and a parameter to denote if the checkboxes need to be selected or unselected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2015 03:46 AM
Kalai, I'm sure this is great but as a developer novice is there any way of showing me how this would apply to my specific scenario? Thank-you!