Azure DevOps Work Item state trigger
This time another example of a Azure DevOps trigger condition expression. In this article I will demonstrate how you can trigger a flow when a state has changed to a specific value in a recently updated Azure DevOps bug work item.
Inspiration
This question from kostukp96:
Can you tell me what I need to specify so that my flow is updated when the state is changed in it?
Power Users Community thread: Change trigger.
Fields
In this example we are using the When a work item is updated trigger action. After a couple of test runs with this action it was clear that the outputs included three fields which are useful for us.
In this setup those three fields are:
– System_State
– System_ChangedDate
– Microsoft_VSTS_Common_StateChangeDate
The goal was to create a trigger condition expression which checks if the value of the State field has changed. We will do this by comparing the System_ChangedDate and Microsoft_VSTS_Common_StateChangeDate field values. When they are the same in the last update the State has changed.
Additionaly, a check will be executed to see if the bug has changed to the ‘Approved’ value in the State field.
Both checks need to be true in order for the flow to be triggered.
Flow setup
In this example we are sending a Microsoft Teams private chat message to the person who registered the bug whenever a Bug work item has been approved for investigation in a specific Azure DevOps scrum project.
1. Add a When a work item is updated trigger action.
From the Azure DevOps connector. Select your organisation and your project. Select the type Bug.
2. Go to the settings of the When a work item is updated trigger action.
Add a trigger condition. The expression can be found below.
3. Add a Post message in a chat or channel action.
Select the Flow bot and Chat with Flow bot. Add a text for the message and include dynamic content fields from the Azure DevOps trigger action. In this example I only used the URL field value.
Use the CreatedBy field value from Azure DevOps for the Recipient field. You can use the expression below. In this expression a slice function is used to only retrieve the e-mail value.
That is it for the setup of this example.
Happy testing!
I love this example. I’m already starting to think how I would use this. We have an ADO template for new requests. It might be cool to post to a Teams channel when that happens. Thanks for sharing!
@Tom, great that this example inspires you to implement something similar. I am happy to always share. I learn a lot from other people their examples too 🙂
Is there a way to replace the system.CreatedBy in between receiving the information and creating a new work item in Azure? I have MS Forms that run into a Flow that creates a “ticket” work item with basic information, but cannot get the “Created By” to change from myself to the user submitting the form.
@Mark, you can have a look at using the Azure DevOps REST API and using bypassRules
https://stackoverflow.com/questions/47806383/update-createdbysystem-createdby-workitem-field-in-vsts-2017
https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/update?view=azure-devops-rest-6.0#make-an-update-bypassing-rules
Thanks for your reply. I’m able to change the “Changedby” through bypassRules and http request, but cannot change the Createdby. I read where “CreatedBy” cannot be changed once a work item is created. If that is the case, then the work item is created under the flow owner (me) and the http request is simply trying to change something that’s hardcoded. Any ideas?