1

Context

I want to create a Power-Automate flow that automatically creates a sub-task in Azure DevOps when the Effort of a PBI is set.

When the Effort field goes from blank to a positive value, the task should be added (using the newly set Effort value as the task's Original Estimate and Remaining Work).

I managed to create a flow that does that using When a work item is update trigger.

Problem

The flow runs too often (whenever the work item changes, as long as the Effort is > 0).

Question

What would be the best way to ensure this flow runs only once per PBI?

Thoughts

  • Perhaps check for the presence of child tasks?
  • Perhaps set a hidden property when adding the task the first time and check that property afterwards?
1

1 Answer 1

3

You could add a trigger condition to the settings of your trigger action. Use the following expression:

@greater(triggerOutputs()?['body/fields/Microsoft_VSTS_Scheduling_Effort'], 0)

enter image description here

  1. Add a Send an HTTP request action directly after the trigger. Use the following URI:

    YourProjectName/_apis/wit/workItems/@{triggerOutputs()?['body/id']}/updates?api-version=6.0

  2. Add a Filter Array. Use this expression for the From

    body('Send_an_HTTP_request_to_Azure_DevOps')['value']

  3. In the where of the Filter Array use the following expression which you add via the advanced mode:

    @greater(length(string(item()?['fields']?['Microsoft.VSTS.Scheduling.Effort']?['newValue'])), 0)

  4. In a condition check if the Filter Array returns no results. If it does, the value of Effort has not been changed in the past and you can safely create your new task

    length(body('Filter_array'))

is equal to 1

enter image description here

4
  • Works like a charm! The only mistake is that the last condition needs to be is equal to 1 instead of 0 because of the first edit. You should probably edit your answer ;) Thanks!
    – Batesias
    Commented Oct 9, 2022 at 18:51
  • Thanks for letting me know about that mistake in my condition :) Commented Oct 10, 2022 at 7:40
  • @Expiscornovus what would be the trigger condition to check only if Titile(string) is updated? like: @greater(triggerOutputs()?['body/fields/System_Title'], 0)
    – Kurkula
    Commented Oct 24, 2022 at 19:24
  • That expression is referencing the Send an HTTP request to Azure DevOps actions within the Filter Array. So for the Title field it would be: @greater(length(string(item()?['fields']?['System.Title']?['newValue'])), 0) Commented Oct 25, 2022 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.