K2 smartforms: View’s Expressions need “Initialize” Rule to start on Form load

When you Nouvelle add a View to a Form, wholesale nfl jerseys the Form will automatically inherit the Rules from the View and at the same time, automatically adds a “When [View] executed Initialize” Rule. This is regardless whether your View has this Rule at all.

Based on K2 smartforms Implementation Tips, you should “Refactor, clean and simplify Form and View Rules” to speed up development and runtime experience.

Now, this tip is only true if you do not need any Expressions on the View to be evaluated when the Form loads.

Let’s see why:

This is my sample View:

View Design
View Design

It has 2 Text Boxes, let us refer to the top Text Box as “Value A” and the bottom Text Box as “Value B”. Lastly, there is a “Addition Result” Data Label, Or which has the following Expression:

Addition Result Data Label's Expression
Addition Result Data Label’s Expression

When I test this View, I should see that the “Additional Result” gets evaluated correctly.

View in run time mode
View in run time wholesale nfl jerseys mode

Next, I proceed to add the View to a Form.

Form with the View added
Form with the View added

Going on to the Rules page now, I see that there is a “When the Form is Initializing” Rule added.

Form Rule(s)
Form cheap jerseys Rule(s)

In the rule, there is an Action running the View’s “Initialize” method.

The Initialize Action
The Initialize Action

But wait! I did not configure any Initialize Rule on my View earlier. So let’s remove it based on the best practice and view my Form in runtime URL.

Form run time. Note that the "Addition Result" did not evaluate.
Form run time. Note that the “Addition Result” did not evaluate.

Hmm… something is wrong. The “Addition Result” Data Label did not show any value. It Wylick should have, since it has the Expression configured and both “Value A” and “Value B” Text Boxes have values in them.

Updating the “Value A” to 2 kicks off the Expression evaluation and I get the value in “Addition Result”. This shows that the Expression works, just that it did not start evaluating when the Form loads.

After updating "Value A", the "Addition Result" is evaluated now
After updating “Value A”, the “Addition Result” is evaluated now

Now, of going back to my Form Rule designing page, I put back the Form Initialization Rule that calls on the View’s Initialize method that with I have deleted earlier. After checking in the Form, I try running the Form again.

It works now!

Expression working now!
Expression working now!

Great! Now we know God that View’s Expressions will only start running on Form load when the View’s Initialize method is called on. So, it does not mean that we should always remove View Initialize method on Form Rules when there isn’t any actions in it =)

Leave a Reply

Your email address will not be published. Required fields are marked *