I am back with another blog topic and this time it is about business rules in canvas apps. If you have been working on Dynamics 365 / CDS, you must be aware of business rules. In case you are no aware of business rules, I strongly recommend to go through the Microsoft documentation before proceeding.
If you are here, I assume you are aware of business rules. But wait, I am not going to discuss business rules again with Dynamics 365/ CDS. Rather I will explain a topic which is hardly discussed – How does Business rule behave in a canvas app?
So I have created a business rule for Contact entity. It’s very simple. Let’s look at the business rule here.
Code view
IF Account Type equals “Financial”
THEN
Set Credit Limit to 1000
Show field Credit Limit
ELSE
Hide field Credit Limit
Clear Credit Limit
Quite simple isn’t it. I am not going to explain in detail here and waste time. Rather, let’s jump directly to the topic of the blog.
I create a simple canvas app. The canvas app show a list of records in a gallery and you have an edit form to edit an individual contact record.
If you observe closely the edit form, I have deliberately kept the fields Account Type and Credit Limit, the fields which are involved in the business process flow. Let’s see whether the business rule have any effect on the canvas app form.
Quite intriguing. If you observe the video above, the business rule had no effect on the detail form. Even when Account type field was blank, the Credit limit field was still shown on the detail form.
Similarly it had no effect on the edit form. When I changed the Account type to Financial, the Credit Limit was not set to $1000. However when I saved the record, the business rule took effect and in the detail form you could see the the credit limit set to $1000.
So what is our takeaway from this. Business rules in canvas app does not work on edit and detail forms.
- Business rules does not work on edit/ view forms in canvas app
- Rules like show/hide, enable/disable have no effect on in canvas app.
- Business rules are enforced while interacting with the data.
Quite a few learning on the way. But wait, the blog is not over yet. I haven’t drawn out the last straw in the puzzle.
All this time, the business rule was scoped to Entity.
To test, I change this to All Forms. And re-activate the business rule.
Below is the observed behavior.
And just as I thought, it happened. Because I have put the scope to “All Forms” now, the business rule no longer fire in the canvas app. So remember to set the scope to entity if you want to fire business rule in canvas app.
You will also like the below posts
Hope this helps!
Debajit Dutta
(Business Solutions MVP)
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.