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.

  1. From the DevOps homepage click on “Organization settings”
  2. Under “Board” you will find “Process”; click on it
  3. Select the process you want to modify
  4. Select “User Story”
  5. 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)
  6. Create another field of type boolean named “Testing Tasks Created” (this field need not be on your page)

You can see it below.

UserStory-AzureDevOps

 

Create Flow

  1. Login to your Microsoft Flow
  2. Go to “My Flow” section on the left hand navigation panel
  3. Click on “New” button on the top of the ribbon
    • Select “Create from blank”
  4. Now search for “Azure DevOps” connection
  5. 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:

WorkItemCreate-Flow

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:

Update-Task-Overall

In action

InAction

 

Leave a comment if you have any questions.

25 comments

  1. 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!

    Like

    1. 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

      Like

      1. Thanks Danish! I got the clear picture now – based on license, the flow execution time is changing.

        Like

  2. 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 🙂

    Like

    1. 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

      Like

    1. 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

      Like

  3. 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?

    Like

  4. 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.

    Like

  5. 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…

    Like

  6. 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?

    Like

  7. 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!!

    Like

    1. 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.

      Like

  8. 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

    Like

  9. 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

    Like

  10. 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?

    Like

    1. 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.

      Like

  11. Hi Danish,

    I keep getting error messages.

    For the tasks, I get:

    ActionBranchingConditionNotSatisfied. The execution of template action ‘Task_Demo’ skipped: the branching condition for this action is not satisfied.

    And for the update task I get:

    ActionConditionFailed. The execution of template action ‘Update_a_work_item’ is skipped: the ‘runAfter’ condition for action ‘Task_Testing’ is not satisfied. Expected status values ‘Succeeded’ and actual value ‘Skipped’.

    I don’t know why I keep getting the error messages. Condition is set to true and false, it should work…

    Like

Leave a comment