Azure Devops set Due Date by an rule

Viewed 5640

I'm try to add an rule in Azure DevOps so that when someone set an Severity, it automatically set the due date according to that Severity. Like this:

Rule screen like i want to add

So the key is to get the date set based on today's date and then add a couple of days. When i try to do it with @Today (what is used in queries) I get an exception:

VS402809: @Today + 28 is an invalid value for field type DateTime. Change the field value and try again.

Someone an idea how to set this rule so it works?

2 Answers

Azure DevOps does not support operation like your. Check this plugin: Work item form one click actions. It contains similar operation:

@Today Macro

This macro sets the value to the current date. This can only be used in "Set Field value" action. Users can also choose to add/subtract certain number of days from @today by using "@today-2" or "@today+3"

Or you can write custom application through REST API to update the date with 2 operations:

  1. Query work items without due date
  2. Update due date

Because of the answer Shamrai Aleksander as given I was thinking how to use the REST API of DevOps without coding. That became Azure Logic Apps.

I've created on when an item is created and one when the item is updated. They both look like this:

Logic app steps

So i get an update when a work item is created, then I Initialize the variable days with an default value of 0. Then i switch on the value Severity (that you get from When a work item is created) and based on that value I set the correct amount of days in the Days Variable. Then I update the work item where I set the due date to add the days we just set to the created date. That is the following expression:

addDays(triggerBody()?['fields']?['System_CreatedDate'], variables('Days'))

This works like a charm for me and is easy to adjust if the days need to be changed.

Related