Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Business Rule on Form load

(0) ShareShare
ReportReport
Posted on by

Hi

I have a parameterized entity form. Based on the parameter, i am setting an attribute value (E.g RequestType  which is an Optionset type) using the script on form load. I have a requirement, i need to show/hide couple of fields based on the parameter.

I wrote a business rule, setting a SetVisibility rule for those fields based on the "RequestType". The scope of the Business rule is "Specific Form" (I tried setting All forms as well).

It appears that the Business rule does not considering the RequestType value which i was setting on form load and executes other condition. But it executes correctly when opening the existing record.

That clarifies me - the value which i was setting on form load does not passing through Business rule on form load.

Can some one help me how to overcome this issue? How to use business rule?

Thanks in advance.

 

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Business Rule on Form load

    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.   

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Business Rule on Form load

    Hi,

    Please read below to get idea on limitations of business rules.

    koenvandevyver.wordpress.com/.../limitations-for-business-rules-in-crm20132015

    Mansoor

  • Suggested answer
    razdynamics Profile Picture
    17,304 User Group Leader on at
    RE: Business Rule on Form load

    Hi Sree

    Fields updated through Business Rules do not trigger the fields on change event of JavaScript. best practice would be not to mix them both because it will be harder to maintain, and makes the solution more complex for developers. It is also good to note the Execution order:

    -System JavaScripts (source code by Microsoft)

    -Custom Javascript

    -Business Rules

    Another factor to keep in mind when deciding whether to implement business logic via javascript or a business rule is this: We cant control  when a business rule is fired as It is always being enforced, whereas with javascript we can control.

    so it might be better to code this logic all in javascript rather than a business rule

    I hope this answers your question, Kindly Verify :)

    Best Wishes, Raz

    Microsoft Dynamics CRM Training Instructor

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,150 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,895 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans