When scheduling resources with Dynamics for Field or Project Service often you need to validate business rules before allowing the booking to be created. The out of the box Booking Rules functionality enables you to do this by writing custom JavaScript, however, this requires a developer and only works on the client side. With North52 it is easy to create Booking Rules using a Decision Table and show messages to the end user, preventing bookings according to your rules. 

For our scenario we want to ensure that bookings are not made for Accounts where the Billing Account is on Credit Hold or when the parent Work Order has not been Scheduled.

North52 BPA Solution

The North52 BPA solution works like this:

  • A Formula of type Validation is set up on the Resource Requirement entity which:
    • Looks up the Billing Account of the associated Work Order and check if it is on Credit Hold
      • If it is then a message is added to the Validation Message variable
    • Looks up the parent Work Order checking for the System Status of Open - Unscheduled
      • If it is then a message is added to the Validation Message variable
    • If there any of the above rules have been met, then the Validation Message is shown to the end user and the booking is prevented

Set up Formula

  • Create a new formula, setting the following values in the Formula Guide:
    • Source Entity set to Resource Requirement
    • Set Formula Type to Validation
    • Select the Decision Table editor
  • Change the Name of the formula to Resource Requirement - Validation - Credit Hold and Parent Work Order Status
  • Click Save

Add the Conditions

  • Select cell A2
    • Select the Source tab and expand the Related (N:1) node
    • Expand the msdyn_workorder (msdyn_workorder) node
    • Expand the account (msdyn_billingaccount) node
    • Expand (Attributes)
    • Select Credit Hold (Value) to add it to cell A2
  • Select cell A4
    • Expand the Credit Hold (Value) node from the previous step
    • Select Yes to add TRUE to cell A4
  • Select anywhere in column B
    • Right-click and select Insert > Insert Condition
  • Select cell B2
    • Select the Source tab and expand the Related (N:1) node
    • Expand the msdyn_workorder (msdyn_parentworkorder) node
    • Expand (Attributes)
    • Select System Status {Value} to add it to cell B2
  • Select cell B5
    • Expand the System Status {Value}  node from the previous step
    • Select Open - Unscheduled to add {Open - Unscheduled} to cell B5
  • Select anywhere in column C
    • Right-click and select Insert > Insert SetVarConcat Calculation (*-)
    • Replace Set Name with Validation Message
  • Select anywhere in column D
    • Right-click and select Delete > Delete Column*

* Note if there was only one rule/validation message to be shown we could simply put the message in the Action column cell without inserting the SetVarConcat Calculation (*-) column.

Add the Validation Messages

  • Select cell C4 and type '* The Account is currently on credit hold so no new Work Orders can be booked at present.<br>'
    • ​​​​​​​The <br> text is a HTML line break that will ensure the next message is on a new line when displayed to the user
  • Select cell C5 and type '* The Parent Work Order has not been scheduled, so this child Work Order cannot be scheduled.'
    • The <br> text is not required for the last message

Set the Decision Table to execute all rows, regardless of match

  • Right-click anywhere on the sheet and select Hit Policy, then uncheck the Exit this Decision Table on First Match option
  • Click Save
  • Your Decision Table should look like this:


Ensure you have Resource Requirement record where the Work Order Billing Account is on Credit Hold and the Work Order has a Parent Work Order with a  System Status of Open - Unscheduled, this will then trigger both rules.

Did you know?

North52 TestShield benefits Dynamics 365 apps testing

Benefits of using North52 TestShield's automated testing framework for Dynamics 365 apps:

1. Accelerate Automated Testing
  • Enables continuous testing of Dynamics 365 apps with speed and agility
  • No-code test designer enables non-developers to build tests
2. Improves Test Coverage
  • Better ROI by a reduction in UAT defects and production defects
  • Defect prevention at early stages of the project life cycle
3. Fix Defects Faster
  • Get fast feedback on the impact of process changes
  • Repeatable automated test execution simplifies problem solving
  • Quickly resolves failing conditions from complex end-to-end tests
4. Faster Delivery and Higher Quality
  • Broader test coverage and fewer defects released to production
  • Reduced risk and faster release cycles through earlier and automated testing
  • Lower costs related to complex test environment management
  • Reduces time to market by validating builds faster
5. Increased Testing Productivity
  • Assist in the generation of automated test scripts that are repeatable and extensible
  • Detailed analysis of test trace logs enable easy detection of errors to be fixed
  • Automation can perform regression tests which ensures system stability while enhancing the application continuously
  • No manual operation increases efficiency and quality of testing

Learn more about TestShield