3 Minute Features : Episode 4 : Business Rules

Wearing ties is a rule that is just bonkers, and not allowing working from home. Thankfully those in CDS are a little more understandable.

Welcome to the 4th video in the 3 minute feature series, on Business Rules

Episode 4 : Business Rules

Transcript

Starting from the Entity, select Business Rules, Add Business Rule

At the top is some tools which we will use later

The first part is a condition, what combination of fields will make the rule trigger. This can be a combination of fields, either both values or one or more of the values

In my scenario, I am going to worry about the status reason for my thing, mimicking an approval process. So, firstly, is the status reason waiting approval?

Then our first action. I want to make the Approver field business required, forcing the user to enter a value.

Next, make the default value of the log field Waiting for approval. Setting values is very limited, you might want a timestamp here, but this is not possible in a rule.

Next, the 2 approval fields need to be visible, allowing my user to enter the values

Now I have achieved everything I wanted on this condition, lets move to th e next condition. If it is not “waiting approval”, check to see if it is approved

Add a condition to the negative side of the first condition, select eh status reason & a different value

This time, we want to still ensure the approver and the log are visible, but lock them both, stopping once it is approved anyone changing the value

But what would happen if the status reason was switched back to waiting approval from approved? The first condition path does not unlock the fields, assumes they are already unlocked. This should be fixed. The business rule editor allows you to copy actions and conditions. Click on the action, select copy.

The select paste. The rule editor then asks you where to paste it to. Select the + where you want it.

We want an unlock rather than a lock, so swap over the action.

Repeat for the log as well.

We can use this techique to cover all the basis, or the default condition, where it isnt Awaiting approval or approved. Copy the Set Business Required, past on the negative condition. Rename it to show we care about maintenance. Same for the show approver and log actions, with the value set to hide.

Once we are done, hit save. This runs a validate as well, proving that there are no missing parts to the actions or conditions. You can rename the rule by dropping down the top option.

This rule is not active yet, we need to activate it, but first the scope has to be considered. Do you want this rule to apply to any time a record is added or updated anywhere in your system, such as imports etc or just when using a form, or just one specific form.

Finaly, Activate. Once activated, the rule can not be edited, only deactivated.

This is then ready to be tested.

I create a new Thing. The default negative path is running now, hiding both the approver & log fields.

As I change the status reason to Waiting approval, the first postive branch kicks in, showing the 2 fields and making the approver mandatory.

If I move it to Approved, the approver is locked, but the field remain visible.

There are a few more options for you in actions, around the suggestions and warnings, so lets edit the rule by deactivating first.

Lets show an error message to enforce that the approver is required. Against the field and a custom tesxt.

Also, we can recommend a value in this condition for multiple fields.

Under details, you can add one ore more defaults for fields, I will just recommend a title for now

Hit Save, then Activate again and lets see it in action

Where the status reason is waiting approval now, we get an error on the approver field, alerting us we need to fill that in. Also, there is a little light bulb that appears against Name, if you click on it, there is a button for you to fill in the form with the fields that we set up

Back to the business rule, there is a snapshot button. This creates a picture of your full business rule to share with others.

comments powered by Disqus
My views, nothing to do with anyone else
Built with Hugo
Theme Stack designed by Jimmy