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.
- 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.
- All Forms. This scope will only work in the model-driven app on a form. So you should only use this for user operations.
- 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.
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.
Then we simple add the Action “Set Business Required” for each field we want to set required.
In our scenario we want to set the fields contact, account, name and description required.
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.
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.
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.
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.
- formContext.data.process has everything you need to work with the Business Process Flow. Use GetActiveStage to get the currently active state.
- the setRequiredLevel property allows you to set the field to recommended (or required).
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.