Attributes re-calculation on forms (dynamic re-calculation)

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Attributes re-calculation on forms (dynamic re-calculation)

Post by Rennur »

USER GUIDE: How to recalculate values in controls dynamically after a user changes some values
Sometimes it may be necessary to dynamically recalculate values in controls of a form after a user has changed values in other controls. For example, let’s say we have a form of the object “MyObject” showing 3 attributes – “Value1”, “Value2” and “Sum”. We want to dynamically show the value of the attribute Sum as Value1 + Value2. We want the system to show the sum immediately after the user changes the values of Value1 or Value2. To do this we need to define a business rule:
 
MyObject.Sum = MyObject.Value1 + MyObject.Value2
 
This is not different from any other business rule. The trick here is when defining the rule to go to the “Advanced” tab and tick the “Use rule in dynamic recalculation on forms” checkbox. If this is ticked Aware IM will automatically fire the rule when any field that the rule depends on loses focus, and display the result.
My non-dynamic BO Rules are executing even when this checkbox is not ticked. My plain text attribute with calculated ticked is getting defined dynamically by this rule during ENTER NEW form entry.

All the rules seem to be evaluated, put on agenda and executed.

Is anyone experiencing this?
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

General guidelines concerning rules:

1. If you use ENTER NEW only rules that are considered to be "initialization" rules are executed before the form is presented to the user. Whether or not a rule is considered "initialization" depends on the setting in the Advanced tab. The default setting is automatic, which means that Aware IM determines it automatically
2. When a user operates with a form Aware IM tracks which value have been changed and whether there are any dynamic rules that depend on the change of the value. If there are, the change of the value triggers recalculation of ALL rules on the server (dynamic or not). However, rules that trigger execution of "service actions", such as CREATE, SEND, REQUEST SERVICE etc are blocked during recalculation
3. When the form is saved Aware IM executes all rules again - this time all actions are allowed. The only exception are rules that are marked as "dynamic" and "do not execute anywhere else". Such rules only execute during recalculation.

With this in mind look at your specific example and analyse the rule log. Then make appropriate changes as required.
Aware IM Support Team
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

1. If you use ENTER NEW only rules that are considered to be "initialization" rules are executed before the form is presented to the user. Whether or not a rule is considered "initialization" depends on the setting in the Advanced tab. The default setting is automatic, which means that Aware IM determines it automatically


I've selected "do not use during initialisation". The rule still executes.
2. When a user operates with a form Aware IM tracks which value have been changed and whether there are any dynamic rules that depend on the change of the value. If there are, the change of the value triggers recalculation of ALL rules on the server (dynamic or not). However, rules that trigger execution of "service actions", such as CREATE, SEND, REQUEST SERVICE etc are blocked during recalculation


So if there is even one other dynamic rule (not related) that depends on a change of the attribute shared between the two rules, both rules (dynamic or not) are executed dynamically.
Is there no way to prevent a rule this and execute a rule on form save or create only?
3. When the form is saved Aware IM executes all rules again - this time all actions are allowed. The only exception are rules that are marked as "dynamic" and "do not execute anywhere else". Such rules only execute during recalculation.
If out of a 100 rules 50 are dynamic, I want those 50 to execute during re-calculation but not the other 50. They are should be only checked and executed when the form is saved/created.
They are not dynamic for a reason and could potentially slow the form entry down by constantly re-calculating these 50 rules.

On form save, they are executed again. I feel they should only be executed when the form is saved.

Am I making any sense? :?

Cheers
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

I'd like to ask a multiple choice question and I'm hoping I might get one or 2 replies to help me determine if I'm loosing my sanity or not.
  • Examine this rule option:
    Image
  • Question:
    When creating a new BO, if you untick the dynamic checkbox for your rule, do you expect:
  • (a) Once triggered by user changing an attribute value on an entry form, by another rule or by a query filter,
    the system to evaluate this rule and immediately execute it changing the value of an attribute. Before you click Save/Create object.

    (b) Once triggered by user changing an attribute value on an entry form, by another rule or a by a query filter,
    the system to determine weather this rule is not dynamic, hence not executing the rule and not immediately changing the value of an attribute. It will place the action on the agenda and the rule will execute once you click Save/Create button.

    (c) Rule is not to be triggered at all during re-calculation of the business object and left alone. The attribute values initially UNDEFINED or DEFINED should remain unchanged. This rule is to be re-checked and executed only when you save the form.
  • Note: "Do not use anywhere else" checkbox works as per default and prevents the rule from executing upon Save/Create.
Cheers
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Don´t know

Post by hpl123 »

Rennur,
I haven´t really used this functionality yet so might not have a useful answer but I would think option a sounds most likely?
Henrik (V8 Developer Ed. - Windows)
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

This is how re-calculation is performed:

Dynamic rules only act as triggers in the user interface. If an attribute value changes and there is a dynamic rule or filter query that DEPENDS on this attribute, then the entire object is recalculated and the results are shown to the user. While an object is being recalculated all rules of the object are evaluated irrespective of whether they are dynamic or not.
Aware IM Support Team
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

This is how re-calculation is performed:

Dynamic rules only act as triggers in the user interface. If an attribute value changes and there is a dynamic rule or filter query that DEPENDS on this attribute, then the entire object is recalculated and the results are shown to the user. While an object is being recalculated all rules of the object are evaluated irrespective of whether they are dynamic or not.


Thanks Support, but I was hoping the get some thoughts on how the developers see this option.

Lock in (a) for Support ;)
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

I choose (b) but prefer (c)
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

Maybe there should be another option
  • (d) If an attribute value changes and there is a dynamic rule or filter query that DEPENDS on this attribute, then the entire object is recalculated and the results are shown to the user. While an object is being recalculated all rules of the object are evaluated irrespective of whether they are dynamic or not.


The question might be, should, they be executed after evaluation if not ticked to do so on re-calculation.
Does this checkbox represent a choice?
The choice of executing the rule action on BO recalculation or after the form is saved.
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

Tough crowd! 8)
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Post by hpl123 »

Rennur wrote:Tough crowd! 8)
8)

Interested thoughts though and I too like to ponder these complex internal things so thanks for sharing your thoughts openly :).
Henrik (V8 Developer Ed. - Windows)
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

Thanks Henrik,

I't is not too complex, not sure why I can't get a response.
I though the post was quite detailed, specific and development revolves around the business rules.
So it's not like I'm asking about some 3rd party plugin or I'm trying to pick a fight.

If it is not a legitimate question, all nonsense, and I should re-read the User Guide the so be it. :)

Cheers
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

It all ultimately comes down to this,

Rules are evaluated and executed on recalculation only or on re-calculation and save.

No matter what triggers BO re-calculation, can a business rule be set to only execute after Save?
aware_support
Posts: 7523
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Post by aware_support »

All rules are executed on both re-calculation and save. The only exception is dynamic rules that are also marked as "do not execute anywhere else". These are executed during recalculation only.
Aware IM Support Team
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Post by Rennur »

This may be general knowledge to some.

Thank you support for clarifying.

So it is not possible to execute a rule only on save.
In that case, it is important to note what triggers the BO to re-calculate, evaluate and execute ALL rules.

Triggers:
1. [Known] When there is a dynamic rule that depends on the changed attribute
2. When there is a filter query in a ref attribute that depends on the changed attribute
3. Shortcut attribute is present on your form.

Be mindful that:

(Correct me if I'm wrong here)

a) Value of an calculated attribute on the form will change every time the user changes any of the value attributes mentioned in rule conditions (dynamic or not).
b) Sometimes if the IS UNDEFINED condition is used can also potentially cause incorrect value to be stored in DB.
c) When your BO uses lots of aggregate functions like calculating a total value of hundreds or thousands of objects, this is done on every re-calculation.
d) Extra care should be taken with PROTECT & READ PROTECT rule actions. Especially when calculated attributes are used to execute them.
e) If you BO has a high number of rules, eg.. FIND rules etc ... that all of those rules will be evaluated causing potential downgrade in performance

Some theories on the way it could be improved.

i) Add the ability to set the rule to execute only on Save.
Ignoring all the dynamic re-calculation triggers. They could still be evaluated, but placed on the agenda to execute on save.
This will not affect anyones' already built apps as the developer would manually have to tick this box.

ii) If that is not possible, consider removing the shortcut & filter query triggers.

iii) Not having every single rule executed, whether you want it to or not, would increase performance

Thank you for reading.

Cheers
Post Reply