Thank you @Raz CRM and @Masoor Sulaiman for your responses and attention...
I would like to understand more on my scenario. Please try to help me.
Rule 1 from the document/TechNet etc
- When you set a field value by using a business rule, any OnChange event handlers for that field will not run. This is to reduce the potential for a circular reference, which could lead to an infinite loop.
Question: Is this applicable in vise versa as well?
In my case I am setting the value dynamically to a field where the business rule is defined to execute based on the value.
Rule 2 from your response /TechNet etc - Execution order
The logic included in your business rules is applied together with other logic in the form that could include system scripts, custom scripts, and other business rules. The order in which this logic is applied will affect the outcome. The order is as follows:
1. Any system scripts are applied first.
2. Any logic in custom form scripts is applied.
3. Logic in business rules is applied.
When there are multiple business rules, they are applied in the order they were activated, from oldest to newest.
4. The Entity scope business rules are executed on the server, after the synchronous plug-ins.
Question: My code also follows the same execution sequence
1. not concerned 2. My form load 3. Business rule
Why it is not executing correctly? Any further insight would be appreciated.
================================================================
Other thought process:
I read somewhere; the CRM generates the scripts and embed along with the form when the business rules are defined with the scope form level and/or all forms. So that it executes at client side. This is equivalent to the Validator controls in ASP.Net.
Question: If the above is correct, then it should work in my scenario. correct?
Also I would like to highlight - In my scenario, instead of setting the optionset dynamically through form load, After the form loads, if choose or chnage the optionset value then the business rules works and dependent fields hide/unhide accordingly.
Please help me to understand the business rules correctly. Also correct me if my thought process or analysis is wrong.
Thanks in advance and appreciate your time.