Power Automate - How to create Azure DevOps work items only once when the trigger is a work item update? - azure-devops-rest-api

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?

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)
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
Add a Filter Array. Use this expression for the From
body('Send_an_HTTP_request_to_Azure_DevOps')['value']
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)
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

Related

Integromat Scenario: One-shot module after iterating through a loop

I have created a scenario where I iterate through multiple modules with an array of data. This works fine.
After this completes, I want to run a module once before the scenario completes.
How do I add a module that won't get called in the loop?
There are few ways to achieve this,
Use Router to Create a new Route that will be triggered after the
first route is complete
Trigger new Scenario via Webhooks after you are done with the
scenario
If you are working with array, then using Array Aggregator or other
Aggregators will allow you to first complete the iteration and then
trigger the module you want to use
I am not sure exactly what you want to do after the iteration is complete, but setting the scenarios as displayed in the screenshot below should help you get started on this,
Using Router
For this you can create a router, the upper hand of the router is always executed first, so the iterator and other operations will be done there. After which, the next hand/route will be executed which will be the module you want to trigger at last.
However, If you want to pass some values from the first hand/route to the last one then you will need to set a variable and fetch it on the second route. See details here : https://www.integromat.com/en/help/converger
Using Aggregator Module
You can either use Array, Text or Numeric Aggregator to aggregate all the iteration operations and then trigger the module that you want to use at last.
As far as my knowledge goes, there is no Integromat default modules that can be configured before the scenario ends. We can leverage the Integromat API in future that is currently in development to do so.
I found a filter to be the most easy way of doing this. Essentially chekcing if this bundle position is equal to the total number of bundles!
If you're interested in doing something on the last iteration only, you can use a filter to check if the current bundle is equal to the total number of bundles
last bundle filter
They won't let me paste pics sigh

Devops custom rule to increment a field

In DevOps, I need a field which can be a counter and get incremented +1 whenever the work item state change from "Done" to "In progress". I tried to have an integer field and set the Rule as mentioned below
condition: when a work item state changes From "Done" to "In Progress"
Action: Set the value of "Field" to "+1".
This rule is changing the value of the counter from 0 to 1 for the very first time only. However the counter does not keep incrementing whenever I change the work Item state from "Done" to "In progress"
Please suggest me an approach to do it.
I have a similar use case: counting the amount of times a work item fails testing (gets moved back from Resolved to Active). Since I don't need a true increment, just want an indication whether this has happened once, twice, thrice or more, I made a couple of rules, one for each increment, like this:
It won't help in any increment scenario, but possibly it helps some people.
Azure Devops does not support increments. You can try to use:
TFS Aggregator (Web Service).
Create rules with Azure Logic App. It contains triggers and methods to update work items.
Create a custom application. Add field like "Need Increment" with default value "false". Create Rule - condition: when a work item state changes From "Done" to "In Progress" Action: Set the value of "Need Increment" to "true". Your custom application updates you increment field and set "Need Increment" to "false".

Is it possible to have a condition for a custom variable?

Suppose I want to create 3 custom release variables on TFS.
variable1
variable2
variable3
can i specify somewhere that to enter a variable3, user must enter variable1 and 2?
i cant prepopulate them myself because the input is quiet dynamic.
for now i am using an ugly method like this:
variable2_MUST_ENTER_VARIABLE1_FIRST
variable3_MUST_ENTER_VARIABLE1_AND_VARIABLE2_FIRST
i wish there is a way to specify some sort of note next to the textbox or something :/
Is it possible to have a condition for a custom variable?
The short answer is yes. But I could not quite confirm if it is what you want.
To set a condition for a custom variable, we could enable a custom condition on the task in the pipeline:
Conditions:
Conditions are written as expressions. The agent evaluates the
expression beginning with the innermost function and works its way
out. The final result is a boolean value that determines if the task,
job, or stage should run or not. See the expressions topic for a full
guide to the syntax.
example:
and(succeeded(), ne(variables['variable1'], ''))
But, this condition for a custom variable will be applied at build/release time instead of entering the value of variable.
i wish there is a way to specify some sort of note next to the textbox
or something
If you want to set the condition for a custom variable on the UI, I am afraid there is no such better way than you are using at this moment. You can add your request for this feature on our UserVoice site (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ), which is our main forum for product suggestions. Thank you for helping us build a better Azure DevOps.
Hope this helps.

how to select multiple checkbox in automation anywhere

I am running a loop where if condition met to select check box. I am unable to to do select multiple check boxes. It select first check box then run loop again but doesn't select next check boxes where condition are met.
enter image description here
To give some insight into what you're probably experiencing - Automation Anywhere object cloning basically operates like Javascript's getElementById in that it locks onto the first available item that meets the criteria you set forth in the object cloning parameters. There is no way to populate an array with these items like Javascript's getElementsByClassName might do.
This is interesting because if there are multiple items on the page that you're trying to work with and object cloning, by default, sets parameters that those items share, you'll only ever be able to interact with the first one.
I would suggest looking into additional parameters that distinguish each check box using Chrome's inspector or the other properties object cloning makes available to select.

Umbraco7 - ContentService.SaveAndPublishWithStatus VS ContentService.SendToPublication

I have an application that uses a combination of ContentService.Saved & ContentService.Saving to extend Umbraco to manage content.
I have two websites in one Umbraco installation I am using those methods to keep content up to date in different parts of the tree.
So far I have got everything working the way I wanted to.
Now I want to add a feature that: depending on which Umbraco User is logged in, will either publish the content or simply send it for approval.
So I have changed some lines of code from:
cs.SaveAndPublishWithStatus(savedNode, 0, false)
To this:
cs.SendToPublication(savedNode);
Now the problem that I am finding is that unlike the SaveAndPublishWithStatus() method, the cs.SendToPublication(); doesn't have the option of passing false so that a save event is not raised. So I get into an infinite loop.
When I attach the debugger and manually stop the infinite loop the first time it calls cs.SendToPublication(savedNode); I get exactly the behavior I want.
Any ideas about how I can get round this problem? Is there a different method that I should be using?
You are correct in saying that it currently isn't possible to set raiseEvents to false when sending an item to publication - that's a problem.
I've added that overload in v. 7.6 (http://issues.umbraco.org/issue/U4-9490).
However considering that you need this now, an interim solution could be that you make sure your code is only run once when triggered by the .Saved / .Saving events.
One way to do this would be to check the last saved date (UpdateDate) in your code. If the content was saved within the last second of the current save operation, you know that this is a save event triggered by the save happening in SendToPublication action. Then you also know that the item has already been sent to publication and that this doesn't need to be done again - thereby preventing the endless loop from happening.

Resources