How does a calculation rule work?
To create a calculation rule, use the SetValue action.
In the following example, when the Labs Local Hematology form is submitted, a calculation rule populates the hidden HemoglobinLabNameLL2 item with the value Hemoglobin if a value is entered in the HemoglobinValueLL2 item.
Calculation Rule to set the value of a hidden field to the name of the lab
Rule Part |
Specification |
---|---|
Precondition |
Evaluate on Form Submission |
Expression |
value = (this.sctHemoglobin.HemoglobinValueLL2.Empty) && !this.sctHemoglobin.HemoglobinLabNameLL2.Empty ? 2 : (!this.sctHemoglobin.HemoglobinValueLL2.Empty) && (this.sctHemoglobin.HemoglobinLabNameLL2.Empty || ("Hemoglobin" != this.sctHemoglobin.HemoglobinLabNameLL2.Value)) ? 1 : 3 |
Action |
Set Value check box is selected. Set Value clause: when value == 1 set this.sctHemoglobin.HemoglobinLabNameLL2.Value = "Hemoglobin" when value == 2 set this.sctHemoglobin.HemoglobinLabNameLL2.Empty = true |