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.
Create Flow
- 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:
In action
Leave a comment if you have any questions.
Thanks Danish for sharing the beautiful article which really helps to fulfill my needs. I have one doubt in trigger interval in MS Flow. in what interval the trigger will be triggered – the flow I created is used to trigger half an hour and i dont see option to change interval time. I wanted child tasks should be created once after the parent feature/bug/tasks created. Kindly throw some lights on that, thanks in advance!
LikeLike
Hi meyyazhagan, not sure I understand you completely but I’ll still try to answer your question. If you have used Recurrence trigger; you may observe in my blog I have not used a Recurrence trigger but instead I have used an event based trigger (two flows in this case) – “when a work item is created” & “when work item is updated”. So as soon as any work item gets created or updated should invoke the Flow.
Also note that if you are using “Free Pricing Plan” for Flow each flow execution might be queued up for 15 minutes. You can read more about pricing here –> https://bit.ly/2uCA7vU
Thank you
LikeLike
Thanks Danish! I got the clear picture now – based on license, the flow execution time is changing.
LikeLike
Hi Danish,
Great article, and it definitely inspired me. The problem I’m having is that the tasks get added under eachother:
TASK1
|–>TASK2
|——>TASK3
Would you be able to make a quick screen cast/video on your exact execution? It would be very helpful 🙂
LikeLike
I’ll try to do that soon. But in meantime make sure when you use dynamic values for example “Area Path” there could be multiple “Area Path” depending on the actions you have added on top of the action you are trying to configure. Please see the screenshot here – http://bit.ly/2Mt0G2t
LikeLike
Hello Danes, the same problem with the task
TASK1
|–>TASK2
|——>TASK3
LikeLike
Make sure when you use dynamic values you select a proper Value from appropriate action; for example there could be multiple “Area Path” depending on the actions you have added on top of the action you are trying to configure. Please see the screenshot here – http://bit.ly/2Mt0G2t
LikeLike
Hi Danish,
Is it possible to only create these tasks for a specific team within a project collection?
Thanks.
LikeLike
Yes, but you will have to hard-code the team in the MS Flow (Power Automate)
LikeLike
Hi Danish, is it possible to add url but as a hyperlink not text to the original work item in to the description of of a Task?
LikeLike
I haven’t tried it but I believe Description field is an HTML text so you could try and add HTML content
LikeLike
Hi Danish,
Is it mandatory to have licence for this Automate task creation on User Story in Azure DevOps using Flow .
Because i have implemented exactly same as show above ,but i am not able to see the child workitems created.
LikeLike
Hi Danish,
Is it mandatory to get license for Automate task creation on User Story in Azure DevOps using Flow.
Because i have implemented exactly same as show above ,but when i create a workitem and refresh, no child workitems are created.
Please help me in this…
LikeLike
You will need license for Azure DevOps as well as Power Automate and access to the DevOps project on which you are trying to create the tasks.
LikeLike
Thanks Danish for this article, do you know how to retrieve the related task work items? think this case, when work item is closed, I would like all the related task work items be closed automatically, but how could I retrieve all the related work items when itself being closed?
LikeLike
There is an action for Azure DevOps called “Get work item children”. You have to supply the work item id and it will retrieve you all the child work items. Check this link: https://danishnaglekar.files.wordpress.com/2020/11/devops-task-commentresponse.png
LikeLike
Hi Danish,
Is it possible to create the separate story when one story is finished ?
I have requirement to create the testing story when development story is completed , is it possible to do that ?
could you pls provide some details how to do that ? , Thank you!!
LikeLike
In step 5 I have used “When a work item is created” instead of that you can use trigger “When a work item is closed”. You would need some way to identify if it is a “development” story that would be your condition, if it satisfy the condition then you can create a new work item of type “User Story” and link the “Dev User Story” as a child or any way you want the link to work. Lemme know if that helps.
LikeLike
thank you for this great information.
LikeLiked by 1 person
Hi Danish,
We have a requirement where we should create new duplicate work item in other board if the previous story is used. For this I’m using “when work item is closed” which will trigger “create a work item” and I’m getting all the details from previous story. The problem here is, for “when work item is closed” our “Iteration Path” changes every two weeks and If I change the Iteration Path value to “null” – flow is not triggered at all. Iteration Path has to be exactly what was on the story that is about to close and it is changing every two weeks in our case – can you please advice any solution ?
Thanks
LikeLike
Hi Danish,
We have a usecase where we want to trigger a new story once the current story is closed, but the problem here is the Iteration Path which is not consistent in our case and it changes every two weeks. I have tried using dynamic “Iteration Path”, but it doesn’t trigger the flow.
Can you please assist with this ?
Thanks
LikeLike
I have the premium license, shared my flow with a generic account, changed the connectors to the the generic account but still the newly created ADO Work items (Stories) say that I created them. The email notification comes from the generic account but the ADO history shows me personally as the creator. Is there a way to set the devops createdby within the flows create work item?
LikeLike
That is because the connection for the ADO is under your name. If you click on the three dots for any of the Azure DevOps actions and check the connection you will see it there. You can change the connection by adding a new one.
LikeLike