Distribution of tasks among the team members can get repetitive, but with this tutorial, it will show you how to create an automated script that will distribute tasks among the list of employees depending on their available hours and positions, and the difficulty of the task. To start, download the sample Spreadsheet here. After downloading, open the Spreadsheet and you will notice 4 different worksheets - Employees, where the list of employees is; Tasks, where the list of all tasks is; Backlog, where the unassigned tasks will be listed; and Task Distributed, where you will see the assigned tasks and to whom they are assigned to. 


Now, follow these steps to create your own Task Distribution Workflow using RAX Editor:


Part I. Getting a Task from Excel


Step 1. Open RAX EDITOR and create a new workflow.


Step 2. Add a Write Line activity that says "Task Distribution Workflow has started.".



Step 3. Drag a While activity and drop it inside the Main Sequence.



Step 4. Create a Boolean variable called terminateLoop.

Step 5. In the Condition input field of the While activity, write terminateLoop = False. It means the loop will continue to execute as long as the value of terminateLoop is False.



Step 6. Drag an Excel Sequence activity and drop it inside the Body of While.



Step 7. In the File Path input field, paste the directory path of the sample Spreadsheet you downloaded earlier.



Step 8. Create an IEnumerable<Object> variable called task

Step 9. Drag a Read Row activity and drop it inside the Excel Sequence.



Step 10. In the Output input field under its Properties, set its value to task.



Step 11. In the Worksheet input field, type "Tasks".

Step 12. Create an Int32 variable called rowTask that has a default value of 2.

Step 13. In the Row input field, write rowTask.ToString. You cannot have a fixed value for Row since you will have to run through each task.



Step 14. Add a Write Line activity that says task(0).ToString + " is currently being assigned.". This is just to inform the user about the current task that is being assigned.



Step 15. Drag an Assign activity and drop it inside the Excel Sequence.

Step 16. Assign rowTask+1 to rowTask variable. This means that once the loop goes back from the start, the Read Row activity will read the next row.



By the end of this part, this should be what your While activity looks like:



Part II. Terminating the Workflow once All Tasks Have Been Assigned/Moved to Backlog


Step 1. Add an If actvity inside the Excel Sequence.

Step 2. In the Condition input field, write task(0).ToString.Equals("<TASK>") = True. As you will notice in the Tasks worksheet, the row next to the last row of tasks has <TASK> as its values. It means it is an empty row.



Step 3. Drag a Sequence activity and drop it inside Then of the If activity.



Step 4. Add a Write Line activity inside the Sequence that says "All tasks have either been assigned or copied to the backlog.". If the condition is true, it means all tasks have been run-through.



Step 5. Add an Assign activity inside the Sequence.

Step 6. Assign True to terminateLoop variable. This will terminate the loop thus completing the workflow.



By the end of this part, this should be what your If activity inside Excel Sequence looks like:



Part III. Getting an Employee for the Task from Excel


Step 1. Insert a While activity inside Else of the previous If activity.



Step 2. Create a Boolean variable called terminate.

Step 3. In the Condition input field of While, write terminate = False. As long as this is true, the loop will continue to execute.



Step 4. Drag a Sequence activity and drop it inside the While loop.



Step 5. Create an Int32 variable called duration and a String variable called type.

Step 6. Add an Assign activity inside the Sequence.

Step 7. Assign Int32.Parse(task(2).ToString) to duration variable. This will assign the duration of the task to duration variable.



Step 8. Add another Assign activity inside the Sequence.

Step 9. Assign task(3).ToString to type variable. This will assign the type of the task to type variable.



Step 10. Create an Int32 variable called rowEmp with a default value of 2 and an IEnumerable<Object> called employee.

Step 11. Add a Read Row activity inside the Sequence.



Step 12. In the Output input field under its Properties, set its value to employee.



Step 13. In the Worksheet input field, write "Employees".

Step 14. In the Row input field, type rowEmp.ToString. Similiar with the tasks, you cannot have a fixed value for this thus the use of the rowEmp variable.



Step 15. Create an Int32 variable called availableHours.

Step 16. Add an Assign activity, and then assign Int32.Parse(employee(4).ToString) to availableHours. This will be used for an If condition in the latter part of this tutorial.



By the end of this part, this should be what your If activity looks like by now:



Part IV. Going Back to the First Employee once the Workflow Reaches the Last Employee on the List


Step 1. Create an Int32 variable called counter with a default value of depending on how many employees are on the list. In the sample Spreadsheet, there are 6 employees thus we will set the default value of counter to 6.

Step 2. Drag an If activity and drop it inside the Sequence



Step 3. In the Condition input field, write counter = 0. The purpose of this will be explained in the latter part of this tutorial.



Step 4. Drag another If activity and drop it inside Else of the previous If activity.



Step 5. In the Condition input field, write employee(0).ToString.Equals("<NAME>") = True.



Step 6. If the condition's true, it means the workflow has reached the last employee on the list. So, add an Assign activity inside Then of If activity.

Step 7. Assign 2 to the rowEmp variable. This means once the loop restarts, the Read Row for fetching employee's data will start reading the values from row 2 again.



By the end of this part, this should be what your new If activity looks like:



Part V. Checking if the Employee's Matched for the Task


Step 1. Drag an If activity and drop it inside Else of the previous If activity.



Step 2. In the Condition input field, write availableHours = 0 OR duration > availableHours OR type.Equals(employee(5).ToString) = False. This condition will check if the employee has enough available hours for the duration of the task and if he/she is matched with the task's type.



Step 3. Inside Then, drag and drop a Sequence activity. This will be for the executed activities if the condition returns True.



Step 4. Add a Write Line activity inside the Sequence that says employee(0).ToString + " is either not matched for the task or has no available hours left. Moving to next employee...".



Step 5. Add an Assign activity, and then assign rowEmp+1 to rowEmp. This will allow the Read Row activity to read the next row in the Employees worksheet.

Step 6. Add another Assign activity, and then assign counter-1 to counter variable. 



Note: The purpose of the counter variable is to check if the task has been tried to be assigned to all of the employees on the list. If the counter equals to 0 and the task is still unassigned, it will be placed in the Backlog because it means there are no more employees matched for the task. That's why the default value of the counter should be the number of employees on the list.


By the end of this part, this should be what your If activity inside Else of the previous If activity looks like:



Part VI. Assigning of the Task


The last condition before assigning the task is to check if the difficulty of the task matches with the employee. There are three levels of difficulty - low, intermediate, and high. High difficulty tasks can only be assigned to senior employees while intermediate tasks can be assigned to senior and intermediate employees. For the low difficulty tasks, it can be assigned to any employee available. This last part of the workflow will be broke down into three parts.


Part VI-I. Low Difficulty


Step 1. Still in the same If activity, drag and drop a Sequence inside its Else.



Step 2. Add an Assign activity inside the Sequence.

Step 3. Create an Int32 variable called consumedHours.

Step 4. Assign Int32.Parse(employee(3).ToString) to consumedHours



Step 5. Drag and drop a Switch<String> activity inside the Sequence

Step 6. In the Expression input field, write task(1).ToString. This is equivalent to the difficulty of the task.



Step 7. Add a new case called Low, and then drag and drop a Sequence inside it.



Step 8. Add an Update Row activity inside the Sequence.

Step 9. In the Worksheet input field, write "Task Distributed".

Step 10. Create an Int32 variable called rowTaskDist with a default value of 2.

Step 11. In the Row input field, write rowTaskDist.ToString.

Step 12. In the Values input field, type {task(0).ToString,employee(0).ToString}. These are the task's and employee's names.



Step 13. Drag and drop an Assign activity inside the Sequence, and then assign rowTaskDist+1 to rowTaskDist.



Step 14. Add an Assign activity again and then assign consumedHours+duration to consumedHours. This will add the duration of the task to the employee's consumed hours.



Step 15. Add another Assign activity and then assign availableHours-duration to availableHours. This will subtract the duration of the task from the employee's available hours.



Step 16. Add another Update Row activity inside the Sequence.

Step 17. In the Worksheet input field, write "Employees".

Step 18. In the Row input field, write rowEmp.ToString.

Step 19. In the Values input field, type {employee(0).ToString,employee(1).ToString,employee(2).ToString,consumedHours.ToString,availableHours.ToString,employee(5).ToString}. This is to simply update the employee's consumed hours and available hours in the Spreadsheet.



Step 20. Add a Write Line activity that says task(0).ToString + " has been assigned to " + employee(0).ToString + ". Moving to next task..." to inform the user that the task has been assigned.



Step 21. Add an Assign activity, and then assign True to terminate variable. This will terminate the inner While loop.

Step 22. Add another Assign activity, and assign 6 (or the number of the employees on the list) to counter to reset it.



By the end of this part, this should be what inside your Sequence activity looks like. This Sequence is inside Else of the previous If activity.



Part VI-II. Intermediate Difficulty


Step 1. Add a new case called Intermediate and then drag and drop an If activity inside it.



Step 2. In the Condition input field, write employee(1).ToString.Equals("Intermediate") OR employee(1).ToString.Equals("Senior"). This condition will check if the employee is capable of doing the task based on its difficulty. If a task is considered intermediate then it can only be assigned to intermediate and senior employees.



Step 3. Inside Then, repeat Steps 7-22 from Low Difficulty case, starting with adding a Sequence activity.

Step 4. Inside Else, drag and drop another Sequence activity.

Step 5. Add a Write Line activity inside the Sequence that says "This task is intended for intermediate/senior employees only. Moving to next employee...".



Step 6. Drag and drop an Assign activity and then assign counter-1 to the counter variable.



Part VI-III. High Difficulty


Step 1. Add a new case called High and then drag and drop an If activity inside it.



Step 2. In the Condition input field, write employee(1).ToString.Equals("Senior").



Step 3. Inside Then, repeat Steps 7-22 from Low Difficulty case, starting with adding a Sequence activity.

Step 4. Inside Else, drag and drop a Sequence activity.

Step 5. Add a Write Line activity inside the Sequence that says "This task is intended for senior employees only. Moving to next employee...".



Step 6. Drag and drop an Assign activity and then assign counter-1 to the counter variable.



Step 7. Outside the Switch activity, add an Assign activity.

Step 8. Assign rowEmp+1 to rowEmp variable.




Step 9. For the last step, go back to first activity inside Excel Sequence which is Read Row. Add an Assign activity before it.

Step 10. Assign False to terminate variable. This is to allow the second While loop to execute again after getting a new task.



And your Task Distribution Workflow is done! You can now try and execute the workflow.