Creating a Custom Performance Management Workflow in ERPNext

ERPNext is a popular open-source ERP platform with numerous business modules. It has gained a lot of traction over the last few years and comes with a lot of industry-standard processes baked into it intrinsically.

This case study delves into a transformative journey, exploring the process of crafting a bespoke Performance Management Workflow in ERPNext system.

Here, we uncover the power of customization, showcasing how tailored workflows can elevate performance management, streamline operations, and foster a culture of continuous improvement.

The HRMS module in ERPNext has some great basic features including even a performance management sub-module.

In ERPNext, the goals and KRAs can be assigned to an employee at the time of appraisal which needs to be added or created for each employee separately.

Below is a diagrammatic representation of the appraisal system that ERPNext provides out of the box.

While this gives a lot of flexibility, it is very tedious to do this for a large number of employees.

This brings us to the use case of one of our customers who required a customized performance management workflow in ERPNext.

Problem Statement

Here is the performance management workflow in ERPNext that our client intended to implement.

  1. All non-contract employees need to be set Goals ( KRA’s) within 1 month of their joining.
  2. The Goals need to be set by the reporting manager of the employee.
  3. Pre-set goals need to be fetched according to the employee’s designation.
  4. The manager should also be able to set goals other than the ones fetched basis his designation.
  5. Timely reminders need to be sent to the reporting manager in case goals are not set.
  6. The goals set for the user in the above process, need to be pulled at the time of appraisal.

Key Issues

Key deviations from the in-built performance management workflow in ERPNext we found are based on the above brief from the client.

  1. Time-bound KRA definition at the time of onboarding
  2. Goals were to be set by the reporting manager instead of HR.
  3. Goals need to be linked to a designation or role and not individual employees.
  4. Goals would be prefetched based on employee role, however, custom goals could also be added if needed.
  5. Timely reminders need to be sent to appropriate action-takers at the right stages. This feature is absent altogether in ERPNext out of the box.
  6. The goals set for the user in the above process, need to be pulled at the time of appraisal from the employee profile.

Proposed Solution

It was clear that in order to make the client’s workflow a reality we will require to customize the workflow in ERPNext setup. These customizations included:

  • Writing custom UI scripts for Forms and DocTypes
  • Creating Custom Doctypes
  • Adding new Workflows, State management, and Rules
  • Using Child tables 
  • Creating custom Fields
  • Link fields across Doctypes
  • Inheriting and extending existing Doctype

Implementation Details of Custom Performance Management Workflow in ERPNext

Here are the details of the implementation and customizations of workflow in ERPNext we did to achieve the custom Goal Setting and Performance management workflows.

1. Enter employee basic Information

Here we are using the inbuilt employee creation form to add a new employee.

2. Defining the Custom Workflow States

To give the workflow a systematic flow to match real-world scenarios, we created custom states for the workflow in ERPNext mimicking the process intended by the client.

Custom states created –

Workflow setup its states & transition rules –

3. Implementing Custom Workflows and Doctypes

While saving the employee profile, we are setting the default workflow state of an Employee to a custom ‘Not Created’ state we defined earlier. 

This indicates that goals are not created for this employee. Only a basic ERPNext employee profile was created.

Next, when we ‘Save’, the employee, the workflow state was to be changed to another custom state ‘Goals Not Set’. 

Further, a button to ‘Set Goals’ was required when the state was set to ‘Goals Not Set’- this is achieved through this custom script:

frappe.ui.form.on('Employee', 
{
    refresh: function(frm) 
    {
	    if (frm.doc.workflow_state=="Goals not Set")
        {
			frm.add_custom_button(__("Set Goals"), 
	   }
}

On click of the ‘Set Goals’ button, it was required that a Goal Setting stage would be activated. This was achieved by 

  • Creating a custom Doctype called ‘Goals setting for Employees’ 
  • We then added a child table in the Designation doctype called “Goals” and linked it to the “Goal Settings for Employee” doctype
  • To activate the ‘Goals setting for employees’ Doctype a custom script was written on click of the “Set Goals” button we defined in the previous step. This script also smartly fetches the defined Goals for the employee based on the designation from a custom child table “Goals” in the Designation Doctype
function() 
            {
		   frappe.route_options = {"name1":frm.doc.employee};
		   frappe.set_route("list", "Goals setting for Employees/new Goals
              setting for Employees")                                                                   
    		 })

frappe.ui.form.on("Goals setting for Employees", 
{
    name1: function (frm)
    {
        cur_frm.clear_table("goals")
        if(frm.doc.designation)
        {
            frappe.call(
            {
                method: "frappe.client.get",
                args: 
                {
                    doctype: "Designation",
                    name: frm.doc.designation,
                },
            callback(r) 
            {
                if(r.message) 
                {
                    var task = r.message;
                    for(var i=0;i<task.goals.length;i++)
                    {
                        var tempObj = task.goals[i];
                        
                        var child = cur_frm.add_child("goals");
                        frappe.model.set_value(child.doctype, child.name, "goal", tempObj.goal)
                    }
                                 
                cur_frm.refresh_field("goals")
                }
              }
              });
        }                    
    },
});

frappe.ui.form.on('Goals setting for Employees',  
{
    after_save: function(frm) 
    {
        frappe.db.set_value('Employee', frm.doc.name1, 'workflow_state', 'Goals Set');
    } 
});
  • Saving the ‘Goal setting for Employees’ form, the workflow state of the employee is updated to the custom  ‘Goals Set’ state through this custom script.

frappe.ui.form.on('Goals setting for Employees',  
{
    after_save: function(frm) 
    {
        frappe.db.set_value('Employee', frm.doc.name1, 'workflow_state', 'Goals
        Set');
    } 
});

4. Reporting

  • Once the Goals have been set for the employee, managers are redirected to the dashboard page. On the dashboard, we created a custom view to show complete statistics of employees’ Goal-setting workflows that are active and completed.
  • This dashboard allows managers and the HR team to view the status of Goal-setting workflows across the organization.

5. Notifications

The system has features of ‘Notification’ where scheduled emails are being sent to designated stakeholders responsible for setting goals for an employee for both existing and new recruits.

Summary

In this post, we saw how to: 

  • Defining custom states for Doctypes
  • Create a custom workflow for Doctypes
  • Linking Doctypes using Child Tables
  • Adding custom Scripts to add UI components, control workflow, and fetch data from Doctypes
  • Creating a custom dashboard to query and show summarised reports

We hope you found this post useful. We look forward to your comments and suggestions on how this could be done better. 

Next Step

Contact us if you have any requirements regarding Customising performance management workflow in ERPNext.

Do subscribe to our blog for more tutorials on ERPNext implementations and customizations.

Please enable JavaScript in your browser to complete this form.
Sign up for latest updates on tech, news and happenings at Bitkraft.
Share your love
Murtaza Paperwala
Murtaza Paperwala
Articles: 1