Are you tired of creating multiple duplicate tasks on a user story in Azure DevOps? There is a way to easy that process – by using Microsoft Flow.
Let’s take an example where we want to create tasks on some user stories which may need testing. We have determined 3 common tasks related to testing: “Create Test case”, “Review Test case”, “Execute Test case”. We would like to automate the creation of these tasks on the user story that may need testing.
Changes to Azure DevOps
Before we start with MS Flow, we will need to make some changes to the corresponding process in Azure DevOps. We will need a toggle control to determine if we need a testing task on that user story or not. Also, we will need another toggle control that will determine if the testing tasks were created or not.
To modify the process you will need to be “admin” on that particular process.
- From the DevOps homepage click on “Organization settings”
- Under “Board” you will find “Process”; click on it
- Select the process you want to modify
- Select “User Story”
- Create a new field (in my case I named it as – Needs Testing Tasks)
- Choose type = Boolean
- Under layout, determine where on the page should it get displayed (you can create your own group)
- Create another field of type boolean named “Testing Tasks Created” (this field need not be on your page)
You can see it below.
- Login to your Microsoft Flow
- Go to “My Flow” section on the left hand navigation panel
- Click on “New” button on the top of the ribbon
- Select “Create from blank”
- Now search for “Azure DevOps” connection
- Search for trigger “When a work item is created”
Note: we would need two MS Flow; one for create and another for update
The overall Flow for “Work Item Create” would look like the image below:
Let’s take a deep dive into each of those tasks.
Flow for work item created
The following images will guide you to show what to enter in each of the tasks.
Flow for work item updated
This one is similar to the create except the condition gets little complicated. In MS Flow you cannot trigger it only when certain fields are updated but rather it gets triggered every time the item is updated. So you would want to put checks in place to avoid running your logic multiple times. So, pay attention to the condition block.
Under condition, click “Edit in advance mode”. The below is the condition you will need to use in the advance mode.
@and(equals(triggerBody()?['Fields']?['Custom_NeedsTestingTasks'], true), equals(triggerBody()?['Fields']?['Custom_TestingTasksCreated'], false))
Overall flow would be as follows:
Leave a comment if you have any questions.