Introduction to ERPNext Workflows
In this video I'll show you how we can use the workflow in ERPNext. We'll see how we can create the workflow and we'll know everything about workflow. So there are two methods to access the workflow. One is of course to use the awesome bar here on top. You can look for workflow and it will show you the workflows which I've already created. Or you can go into settings if you have the access to this. So you will go into settings and in settings down here you can see workflow.
So there are three type of things that you have to remember. One is the workflow state and one is the workflow action. Action is the type of action which a user is going to take to complete the workflow and state is the state of the workflow at that on which state or on which stage the current document is. So I'll explain you with the help of example. You can click on workflow or we'll open the workflow list and you will see all the existing workflows available. I will just click on add a workflow.
Creating a New Purchase Order Workflow
And we will give it a name for example, it is Purchase Order 2024. Maybe in next year you might change the workflow. So right now we'll be using Purchase Order 2024. Workflow will be for a specific document type, so I will type the document called purchase. So this is the purchase order. First of all, you need to look for the states and transition rules. These are the two important sections that you need to really work on. And here, if you see by default, it sends the email alerts on the next possible action. That for example, if it is a document is sent for the approval, the next person has to receive the approval email that you have to approve for it. So you can do that. For the time being, I'll disable this email alert.
Designing the Approval Process Logic
Now here are the states, so what will be the states during this particular workflow for this? This is your process and I'll name it, uh, process name will be Purchase Order Process. Of course the process is a complete process but we will be only referring here the approval mechanism. So this might be from any department requester. So here is the checker and here is the approver. So there are three type of people or three group of people involved in this entire process.
So let me show you what will be in the activities. First activity will be the person who will be requesting it. So from where it has started? The process has started with the request for preparing the purchase order and from there, submit for review, submit for approval, and here the action will be approved. I mean I'm making it simple. I'm not making it that if it is not approved so what will be done. So we will take the normal case scenario in that case. Now if the approval limits are there of course, so it will be criteria and all of that. So we'll talk about that as well while we do it in the ERPNext. Here, for example, the submit for approval is the state of, is the action that we are going to take. What will be the state once this person will submit for review? Document state will automatically be changed so it will become waiting for review. And then the person will review it. The moment review is completed, then the next state will become at this state, waiting for approval. So the new state after approval will become approved.
Now if you see how many states are there? States are draft, waiting for review, waiting for approval, and approved. These are the states. And how many actions are there? One action is submit for review, submit for approval, and approve. So same thing we have to configure in the system.
Configuring Workflow States and Permissions
So we have to tell the system that how this workflow has to be created. So we'll be creating the workflow inside the workflow in ERPNext. As we mentioned that how many states should be there? One state of the document was draft, so it will be available there. Second state of the document was waiting for review, and we'll create the state if it is not there. Then we'll be waiting for approval. This is also one of the state, and another state is approved. This is already there.
Now, if you see, once it is approved, the document should be submitted. Submitted means that after that document cannot be modified. Of course, at this state, we want the document to be submitted, but who should be able to modify at this state? Of course nobody can modify, but we need to mention someone who should be able to modify at this state. Who will be able to modify? We'll say Purchase User, for example. Purchase User will be creating the document. So who will be reviewing it or who will be allowed to edit this document? So at draft state, of course, Purchase User will be able to edit it. At this state, when it is being reviewed right now, who will be able to review that? Of course, the next person who has to approve, he will be Purchase Manager. All right? So now who will be approving it? So waiting for approval, who will be allowed to edit at this stage? At this stage only one person will be allowed to edit who is authorized to uh approve this purchase order. It could be any manager, operational manager, any senior manager, any role that you have assigned. We mentioned the Head of Department will be allowed.
Now these are the states that we have defined. So there are four states. These are optional fields. You can update the field also if any specific field is there uh that you want to update, so you can choose those fields here and you can choose what will be the value based on the click. So if the purchase user at this state, for example, waiting for review, once the state is changed at this state what will be the updated value? You could it could be anything, for example if I want to add something in the remarks. So we can use that as well. Otherwise, we will leave it blank. This is not mandatory, this is optional, but in some cases you might need it. So we'll use it at that step. We'll keep it simple.
Defining Workflow Transition Rules
Now is the transition rule. So this is the transition rule which we mentioned earlier here. Action is reviewed and before the action is the state. It is waiting for. After the action, what is the state? It is waiting for approval. Before approval, what is the state? It is waiting for approval and after approval, what is the state? It is approved. Same thing we have to configure in the system. Now we'll come back here to the workflow rules and we will define this transition rule here. When it is draft, you can see here first state was draft. So when it is draft, what will be the next action? Next action will be submit for review. So we'll create here submit for review. Next state will be what? So here when was this once this person will submit for review, this person from the draft will submit for review, it will become waiting for review. So we say waiting for review. All right. So we already created this state. So who will be allowed to convert from this state to this state? Here the person will be Purchase user. So purchase user will be allowed to convert from draft state to waiting for review state.
Now we'll go next. Now what will be the next state? The start state is of course the same, waiting for review. The person will start from waiting for review and what the person will do? He will take an action, review. Or review, review will be the action which a person is going to take. If you remember, review will be this action. This is the action. This is the action. This person will review it and what will become next state? Next state will be waiting for approval. So we do here. So next will be waiting for approval. So who will take this action? Review action will be taken by purchase manager. All right.
So now we move next. Next state will be, initial state will be same, waiting for approval. And what will be the action? Action will be approved. Approve will be action. You can see here the next action is approve and what will become next state? next state will become approved and who will be allowed to do it? HOD. All right?
So if you see here, this is the transition rules and this is the transition states. So we first created the states that we want to have within this purchase order, and then we mention what will be the transition rules.
Activating and Demonstrating the Workflow
So I'll click on save. Now you can see that custom field workflow state in purchase order is added. So automatically one field has been created inside the purchase order. So we click on save. Now right now the purchase order 2024 is created but it is not active. So if I open the purchase order now, so we'll create a new purchase order now. Purchase order, and I will give it a name.
Now if you see right now, from the draft directly it is showing me submit because the workflow is not active. I'll just activate this workflow and save. Now for every purchase order it will ask for the approval. If I go here now to purchase order again, now I can see action. So I will not click on action, but what will be the first action? First action will be submit for review. If you see this action, action will be submit for review. I submit this review now it will be changing the state to waiting for review. So now you see here from draft state, person has clicked on submit for review, next state has been become waiting for review. Now what will be the next state? Next state is waiting for review and person will click on review, and the state will become waiting for approval. You go back to purchase order and I'll click on action and it will be reviewed. Now the state will automatically be changed to waiting for approval. And now the person has received the email for example, what will be next action? Person will go back and check everything is fine and click on action and approve.
Now you can see the document has been approved. Approved state has been changed and now document is also submitted. We can't make any changes in this document now because the document has been submitted and everything is fine. So this was all about creating the workflow in ERPNext. So we have seen with the help of a diagram also and we have seen how we can create the transition rules and states.