D365 SalesPut validation on Business Process Flow
CRM business process flow allows users to enter data in steps which makes it simple and don’t required to scroll down all the way to bottom of form. A single business process flow can be divided into small steps to achieve the same and enter the data easily.
But user may have requirement where a person should not move to the next stage. If it is based on the field than there is no problem, user can simply set the field required and get requirement fullfilled.
But what if user should not allow to move to the next stage until a record of related entity is not present. For example, an account should have a phone call or an appointment to move the next stage.
Or in our case an Incident should have few documents attached to it before moving to the next stage.
While moving from Reporting to Insurance stage it should have below listed document. Otherwise it should display an error.
To achieve this requirement, we can write a plugin on the business process flow. But we must understand the structure of the Business process flow.
- While creating a new business process flow it creates a new entity with the same name.
- Which holds the related entity name
- Current stage
- Record with which it is associated
- When creating a record with the having business process flow.
- Name of the business process flow: Incident Business Process
- Active stage: Reporting
- Record name: 20171025–ESTDEL55-1
Plugins- Write Code:
We need to write code and need to compare the current stage with previous stage and check if required document is present or not.
Using the above information user can write a plugin and stop the user to move the next stage until required document is provided.
Once you have completed the code you need to register the plugin on update of business process entity.
Message Name: update
Filter attribute: activesateid.
Event stage: pre-operation
Register Image: PreIamge
Once you have completed your plugin and registered it. You can simply test it by moving to the next stage without having the required document. You will receive the below error.
Until user not provides the document he will not be able to move to the next stage
You can write a plugin to prevent a user from moving to the next stage.