Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Dependent Business Rules

  • 1.  Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 20, 2020 11:42 AM
    Hi,

    I have 2 business rules that need to execute in a specific order.

    The first takes 2 fields, calculates a percentage value and is working ok.
    Calculates % value

    The second references the output from the 1st rule
    It does not trigger when '% of premium' is updated by the 1st rule, only when the record is saved.

    I tried changing the order in which the rules were activated but that doesn't seem to make a difference.
    Execution Order of Business Rules in Microsoft Dynamics CRM

    Both rules have scope set to "All Forms". All fields referenced in the rules are present on the form.

    Can anyone advise on the best way of setting 'Rationale' as Business Required based on the '% of premium' value, without having to save the record first and without using JS?


    Thanks in advance,

    ------------------------------
    Sean O Malley
    AIG
    ------------------------------
    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 2.  RE: Dependent Business Rules

    TOP CONTRIBUTOR
    Posted Oct 21, 2020 02:46 PM
    Sean - I have no idea if this would make a difference, but have you tried combining them in the same business rule? That might allow the fields to be evaluated all at the same time as they change rather than checking them in 2 separate rules.

    ------------------------------
    Jill Vazquez
    Technical Specialist - CRM
    Bioventus, LLC
    Durham NC
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 3.  RE: Dependent Business Rules

    GOLD CONTRIBUTOR
    Posted Oct 21, 2020 06:29 PM
    I was thinking the same as @Jill Vazquez. You might have to restructure how you think about the logic if you do, because you can only have an additional condition in the "else" branch of a business rule.

    Another option that might work is creating a calculated field that can have conditions in it, as well. ​

    ------------------------------
    Chad Althaus
    IT Digital Transformation Analyst, Low Code Apps & Business Automation
    Bray International, Inc.
    Cypress TX
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 4.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 22, 2020 09:51 AM
    Thanks for the responses, 

    @Jill Vazquez, I tried to combine the two business rules but I couldn't get the logic ​to branch correctly
    As Chad mentioned, I can't control where the conditional branches are added. To keep everything in one business rule I would need a conditional branch after the % value has been calculated which isn't possible.
    I can't find a way around this.




    @Chad Althaus, I tried a calculated field but it doesn't calculate until the record is saved so I ran in to the same issue.

    Thanks for your suggestions,​

    ------------------------------
    Sean O Malley
    AIG
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 5.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 22, 2020 03:57 PM
    Edited by Jonathan Blackham Oct 22, 2020 03:58 PM
    Sean,

    I've encountered something similar before and it was very counter-intuitive.  You need to redesign your business rule to evaluate along a negative path criteria so you keep getting the conditions option.

    I've included a visual example of how this would look in the designer and how the logic should approximate in the tool.  You might end up with an infinite loop on clause #3, so I would check that, but this is the structure you would want to go for.



    IF
         Premium less than 0 OR Proposed Budget less than 0    (#1)
    THEN
         n/a  (#2)
    ELSE IF
         Premium greater than 0 AND Proposed Budget is greater than 0 AND % of premium is greater or equal 0.5  (#3)
    THEN
         Set % of premium to Proposed Budget * 100.00  (#4)
         Set % of premium to % of premium / Premium  (#5)
    ELSE IF
        Premium greater than 0 AND Proposed Budget is greater than 0 AND % of premium is less than 0.5  (#6)
    THEN
        Set Rationale as Not Business Required (#7)
    ELSE
        Show field Rationale (#8)
        Set Rationale as Business Required (#9)



    ------------------------------
    Jonathan Blackham
    Sales Operations Specialist
    Valin Corporation
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 6.  RE: Dependent Business Rules

    GOLD CONTRIBUTOR
    Posted Oct 22, 2020 05:20 PM
    @Jonathan Blackham, thanks for mocking this out fully for this scenario. I'd begun to do this but hadn't worked the logic through all the way. This is what I intended  with my initial response. I've had to get quite creative with structuring business rules, and beginning with a reverse condition is very helpful to allow nested conditions below.

    Another note here is that you will need to apply some action in the step 2, even though you don't care about that branch. You can apply some business rule that is always true such as to make visible the primary field or set as Business Required the "Created On" field.

    ------------------------------
    Chad Althaus
    IT Digital Transformation Analyst, Low Code Apps & Business Automation
    Bray International, Inc.
    Cypress TX
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 7.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 22, 2020 06:26 PM
    @Chad Althaus, you are correct.  ​​Thanks for catching that.  You definitely need an action step in step 2.  I meant that to specify that it didn't matter what you put in there.  In this example I would recommend that you undo some of the steps that are taken (i.e. show fields, set business required, etc.) in the later steps back to the original values.

    ------------------------------
    Jonathan Blackham
    Sales Operations Specialist
    Valin Corporation
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 8.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 28, 2020 05:55 AM
    @Jonathan Blackham, thanks for the detailed instructions.

    I created a rule following your steps (and put actions in Step2) and with a couple of additions it works fine on initial create of the record. But if any of the fields are updated,  the logic doesn't always work as planned.

    I've had to make these fields mandatory in all cases for now due to time constraints but I'll be reviewing again to see if I can get this logic working before releasing to Production.       ​​​

    Thanks for your assistance here,

    ------------------------------
    Sean O Malley
    AIG
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 9.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted Oct 29, 2020 02:50 AM
    Hello
    Just my to 2 cents. What about to opt for a client side JavaScript in that case?
    Regards
    Heinz
    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 10.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted 24 days ago
    Hi all,

    I spoke with Microsoft support to see if there was any way to get the business rules to run in a certain order and they suggested naming them alphabetically but that didn't work.
    I had previously tried activating them in the order I wanted them to run but that didn't work either.

    So I reluctantly used client side JavaScript

    Thanks again for your input here.

    ------------------------------
    Sean O Malley
    AIG
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 11.  RE: Dependent Business Rules

    GOLD CONTRIBUTOR
    Posted 23 days ago
    Edited by Junbin Duan 23 days ago
    Hi Sean,

    Have you thought of using workflows instead of Business rules? Workflow can be designed as on-command and child real-time, and be called it at the end of other workflows or in certain condition to control the sequence.

    Thanks,
    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 12.  RE: Dependent Business Rules

    SILVER CONTRIBUTOR
    Posted 23 days ago
    Edited by Sean O Malley 22 days ago
    Hi Junbin,

    I had a look but I didn't think it was possible.
    The action (set field: required/not required) needs to occur before the user hits save. Would workflows, even real-time, allow me to do that?

    Regards,

    ------------------------------
    Sean O Malley
    AIG
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


If you've found this thread useful, dive deeper into User Group community content by role