I’m going through the rules in a SmartForm and associated views to squash a bug, when I came upon an Execute a Form method action in the When the Form is Initializing rule.
Trouble is, the method to call is the Initialized method.
Would that even work?
Would calling the Initialized() method from within the When the Form is Initializing() rule work? Because at the point where you’re calling it, the form is still initializing!
Welp, it turns out it actually will work.
Here’s how to test:
-
Create a new SmartForm and add a single DataLabel to its canvas.
-
Create a When the Form is Initializing rule.
-
In the Rule Designer, add two Transfer data actions.
Format the first Transfer data call to put the current value of Data Label into the Data Label, followed by a space and the word “Initializing()”.
Do the same for the second Transfer data call, except the words are “Return to Initializing().” -
Create a When the Form is Initialized rule.
-
In the Rule Designer, add a Transfer data action that follows the same format as the others, but with the word “Initialized()”.
-
Finally, open the When the Form is Initializing rule again, and insert a new Execute a Form method action between the two Transfer data actions. Point the call at the Initialized() method.
- Close the Rule Designer, click the Finish button, and then browse the form using either the testing URL or the runtime URL.
You should see this text appear on the form:
Initializing() Initialized() Return to Initializing() Initialized()
The Initializing() method was called first, followed by the call to the Initialized() method that we inserted, followed by a return to the Initializing() method; once completed, the Initialized() method was called as normal.
How about that?
Excedrin® is a registered trademark of the GSK group of companies. TYLENOL® is a registered trademark of Johnson & Johnson Consumer Inc. And no, I wasn’t actually seeking sponsorship of any kind.