Set form fields required based on Business Process Flow Stage

It is imperative to guide the user through each stage of a Business Process Flow. We can set a lot of fields to required in a business process flow stage. However this does not give the best User Experience. In my previous blog I showed how we could use “Task Groups” to keep the stage clean. But now we need to guide the user what fields are required exactly on the form for this stage. This is also possible using Business Rules. Let me show you how!

This blog is part of a series about guiding users and teams through their work. This post is part about an advanced scenario called Task Groups. Click here for an overview of all related post regarding Task Groups. I also added a sample solution you can import in your own development environment so you can see the entire concept in action!

Keeping people in their flow of work by utilizing Asynchronous work or asynchronous processes is one of the key benefits for Business Process Flows. I have written down my thoughts on this subject here. Find out what asynchronous work is, how Business Process Flow can help and more advanced scenario’s.

Set the Business Rule Scope to All Forms

Let’s start off by creating a Business Rule in our Case table. We want to use the Business Process Flow stage in our condition. And to do that you need to know about “scope”. Scope comes in 3 variants.

Shows a Business Rules highlighting the Scope option.
Business Rule Scope
  1. Entity. The entity scope will trigger the business rules on the server. Which means it also enforces Bulk edit or data changes through the API.
  2. All Forms. This scope will only work in the model-driven app on a form. So you should only use this for user operations.
  3. Specific form. The same as All forms, except only for the form you selected.

We can not use the Business Process Flow inside the scope Entity. So for our example we change the scope to “All forms”. Now we can change the source in the rule of the condition to Business Process.

Shows the Business Rule designer. After we changed the scope to All Forms we can now change the Source of the rules in the condition to Business Process
Business Rule Source can be changed to Business Process

The Business Rule to guide them all

Now that we can access the Business Process Flow in the condition it is fairly straightforward. Select Process Name for the field and you will get the option to select “Value with Stage” inside the type field. This will allow you to select which active stage the Business Rule should trigger on. In our example it’s the “New” stage.

Shows the condition of the Business Rule. This condition selects the Stage new in our Business Process Flow
Overview of the Condition where we select which stage we want to trigger on.

Then we simple add the Action “Set Business Required” for each field we want to set required.

Shows the properties of the Set Business Required Action used in the Business Rule
Business Rule Set Business Required

In our scenario we want to set the fields contact, account, name and description required.

Shows an overview of the Business Rule we use to set fields required based on the Business Process Flow Stage
Overview of the Business Rule to set fields required based on the Stage

On to the next issue

Now we get exactly what we want. On the Business Process Flow Stage “New” the fields are required. Our “Task Groups” help our users do their work inside the form.

Shows the form where our business rules enforces all fields we have set to required to be entered. Even when the record has not been saved yet.
Requirement on new case

Why is it then that I am talking about an issue? Do you see in the picture above what might be something I don’t like? The fields are already required when we have not created the record yet! I actually liked that about our previous solution. A customer could report an incident quickly and after which we could take our time and gather all required details for this case to start investigating.

The second rule on the condition of the Business Rule where the source is Entity and created by should contain data
Business Rule Created By Contains data

This is still possible when we add a second rule to our condition. We can check if the “Created By” field has a value. Please be advised that for this to work the “Created by” field has to be on the field. Remember we have made our Business Rule work on the form, which does it’s logic on the client side inside the browser. That is the reason it has to be on the form. The good news is that you can hide the field if it has no function on your form.

Shows the end result. The Business Rule sets fields required based on the BPF stage but not on a new case.
The end result of our Business Rule

Set field “Recommended” not available in a Business Rule

It is great that we can set fields to be required based on the Business Process Flow Stage. However I do miss the option to set the “Recommended” option for a field. If you don’t know, instead of making a field optional or required, you can also recommend a field to be entered. In the gif above it’s the Name field when the record has not been saved yet. This gives us another option to guide the user in a form.

If we want to achieve this we have to resort to JavaScript. This is not the subject of this blogpost, but to get you started take a look at the following documentation:

This technically concludes the “Task Groups” concept. We can still guide the user the way we want inside a Business Process Flow. But instead of cluttering the UI of the Business Process Flow Stage with all the required fields, we use the Form for that! For my next post in this series I want to improve how the Stage fields actually look.


Leave a Reply

Your email address will not be published. Required fields are marked *