in my last blog post, I created a workflow for master data which was based on the template.
In this blog post, I will create a new workflow from scratch for Sales Return Order approval.
First what I will do is navigate to workflows.
Then, a list of enabled workflow will appear, and what I need to do is click on the New action button.
A new window will open where I will enter
- Workflow Code
- Workflow Description
- Workflow Category
and field Enabled for now I will leave on false.
Next step is to create workflows events, workflow conditions, and workflow responses.
First of that I will choose workflow event – Approval of sales document because I will create workflow for Sales Return Order.
After that, I will click Always in On condition field.
New window will open with all fields from sales header and sales line tables. Here I will specify that I want that my workflow only works for Document type = “Return order”, and when the document is in Status = “Open”.
As you can see, Business Central gives us broad possibilities to create workflows based on values in many fields. One example can be when the amount of sales return order is greater than 1000.
I will confirm the condition by clicking on Ok, and then I will click on Select responses in Then response field.
New window will open where I will choose available responses.
- first, we will set a record restriction for the document on which workflow is working.
- then it will set the document to Status = Pending approval.
- after that workflow will create approval request for Direct Approver.
- finally, it will send an approval request to the Approver.
Next, I will create another action which will occur when a document is sent for approval.
- when approval process is rejected from the approver it will trigger set of actions.
- a user should enter the comment on Approval comments page.
- the system will reject approval request for the record and create notification
- system will automatically reopen the document.
Reopen document is important because if document approval is rejected system will leave the document in status “Pending approval” and the document will not be in filter for new approval when trying to process approval (we set that approval will be started only for the document in status = open).
- when there are no pending approvals for return order document – we see that “On condition” that pending approvals is filtered on 0.
- the system will remove record restriction
- the system will release document and it will be ready for posting
- when approval for sales document is canceled – user cancels the approval which is in status “Pending approvals”
- the system will cancel the approval request
- the system will reopen a document
- the system will remove record restriction.
- when additional approval is needed
The number of pending approvals is greater than 0 system will:
- send approval request for the record
- show message that for this document Additional approval is needed. This is the message which user can modify when creating a new workflow.
Now when we create a new Return order and click on “Send approval request” system will generate approval entries for users who are valid for approval.
In my case I have an approval chain (MARIN-> his approval is RENATO.FAJDIGA user, and approver for renato.fajdiga is RENATO) so it will generate 3 approval request.
- because MARIN user also is defined in approval chain, return order is automatically approved by MARIN
- for approver RENATO.FAJDIGA we have Open approval
- for approver RENATO we have Created approval
The difference is that for now only user RENATO.FAJDIGA has an approval request.
Now when I log in with user RENATO.FAJDIGA and approve document I will receive the message:
This message was defined when we created a workflow.
And the last situation before document ready for posting is shown in the picture below.
We can see that RENATO.FAJDIGA approved the document, and that we have an open approval request for RENATO.
After he approves the document, it will change status from Pending approval to Release and it will be ready for posting. In Approval entries page all 3 entries will be in status Approved.
That is all for this blog post (big thanks to my colleague Marin who allow me to use his account for this demo), next time we will integrate Business Central with Flow to extend Business Central.
Renato 🙂Tags: Dynamics 365 Business Central Workflow