API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Updating two check boxes at once
I was helping out someone on a project and an odd request came about. They wanted to update two check boxes with one click. For this project, there was the ability to update different fields based on a dialog box. For example, take a look at figure 1. The user would select the field(s) they could update and then they would be able to update them, like in figure 2.

The problem was, if the user said they wanted to update the state, they needed to update the city. But they could update the city without updating the state. So, basically, when the user clicked the check box next to "Update State", the check box next to "Update City" needed to be checked automatically and couldn't be unchecked. The "Update City" could be checked or unchecked if "Update State" was unchecked. This was actually easy to solve.

First, the "Update State" check box needed to have "refresh fields on keyword change" enabled. It already had that because the second column (look at figure 2) needed to show or hide based on the first column being checked. So, when the user clicks on "Update State" the dialog box is going to automatically refresh.

Second, the Input Translation formula on the "Update City" check box would take care of automatically checking the box. This was done through a simple formula:
@If(UpdateState = ""; @ThisValue; "1")

This formula says that if UpdateState is blank (unchecked), then leave the value alone - the field can be checked or unchecked and it won't be affected. If UpdateState is non-blank (if it's checked), then the Input Translation formula is going to force the value to "1". That's the alias for the value when the field is checked. So, it is forcing the field to be checked if UpdateState is non-blank.

The nice side-effect is that the "Update City" field also has "refresh fields on keyword change" enabled so the drop-down in column 2 will show or hide based on the field being checked or unchecked. If the user clicks on the "Update State" check box, the drop-down for the state will show, the "Update City" check box will automatically be checked, and the drop-down for the city will show. So doing that one click updates multiple things all at once.

And all through one simple translation formula.