aggregator-cli icon indicating copy to clipboard operation
aggregator-cli copied to clipboard

Get Iteration Start and End Dates, based on Iteration ID

Open mmuresan opened this issue 4 years ago • 8 comments

Feature Request

When the Work Item's iteration is changing, I need to update a custom field in the work item, with the new iteration's end date. That means, I need to be able to read the start date and end date from the Iteration (if it is set for that iteration). Is that possible now?

mmuresan avatar Apr 16 '20 16:04 mmuresan

Currently this is not possible, if you're interested: I think I can provide you a code snippet for your rule code, which can support you in getting the information. It will be a workaround until a proper solution would be available.

BobSilent avatar Apr 19 '20 10:04 BobSilent

Please. If you can provide a code snipped to get the start and end dates from the iteration using the iterationid, which is already available, I would be able to solve this issue. Thanks.

mmuresan avatar Apr 19 '20 10:04 mmuresan

It is not nice in rule code, but it should do the work. btw. I did not test it.

You need

  • a PAT
  • URL
  • teamproject name
  • the node id, here 11111
var clientCredentials = new VssBasicCredential("PAT", "<token>");
var devops = new VssConnection(new Uri("https://..."), clientCredentials);

var client = devops.GetClient<WorkItemTrackingHttpClient>();

var nodes = await client.GetClassificationNodesAsync("<teamproject name>", new []{ 11111 });
var node = nodes.Single();

then you can access e.g. node.Name or node.Path

var startDate = node.Attributes["startDate"] as string;
var finishDate = node.Attributes["finishDate"] as string;

the string will look like that:

"attributes": {
    "startDate": "2017-03-22T00:00:00Z",
    "finishDate": "2017-09-05T00:00:00Z"
},

BobSilent avatar Apr 22 '20 15:04 BobSilent

Thanks. I'll try it out. BTW. Can I create inside the rule one or more common reusable methods to call multiple times inside the rule?

mmuresan avatar Apr 22 '20 16:04 mmuresan

please see the advanced examples there is an example with a method which get called several times in the rule

BobSilent avatar Apr 22 '20 20:04 BobSilent

It would be very nice to have these examples in the main documentation. After testing this, I might contribute to this extremely nice project and add it to the Examples documentation.

Thanks again.

mmuresan avatar Apr 22 '20 21:04 mmuresan

Can I call multiple times, in the same rule, store.NewWorkItem?

mmuresan avatar Apr 22 '20 22:04 mmuresan

Sure, this is supported

BobSilent avatar Apr 23 '20 13:04 BobSilent