Get real starting date of an item

Description
victorien
Posts: 7
Joined: Wed Mar 14, 2018 1:41 pm

Get real starting date of an item

Postby victorien » Fri Apr 06, 2018 11:06 am

Hello, I am having a little trouble getting starting date of some items.
I am trying to do this in a velocity script live report page.
I made a custom field called start date but it is not always filled.

I would like to know if it is possible to somehow get the real starting date value of an item (the date when the item status went in progress). Just like we can see if we click "history" of the item.

I would then like to set the result as string (ex 2018-12-02).

Jürgen
Posts: 43
Joined: Tue Sep 12, 2017 1:02 pm

Re: Get real starting date of an item

Postby Jürgen » Mon Apr 09, 2018 10:38 am

Why not use IWorkItem.getCreated() ?

ALMighty
Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

Re: Get real starting date of an item

Postby ALMighty » Mon Apr 09, 2018 12:38 pm

Jürgen wrote:Why not use IWorkItem.getCreated() ?


I think it is not that easy because the thread creator does not want to know when a work item
For that purpose one must get the history of a work item and traverse through it.

victorien wrote:I would like to know if it is possible to somehow get the real starting date value of an item (the date when the item status went in progress). Just like we can see if we click "history" of the item.


Yes you can, with the DiffManager. You can get the Diffmanager withe the following code line:

Code: Select all

#set( $diffman = $trackerService.getDataManager().getDiffManager() )


And then you can use the generateHistory method, the first parameter is the work item (not the work item ID, the whol work item object as you get it e.g. from queryWorkItems) and the second, the list of ignored fields, can be null I guess.

The method generateHistory gives you an array of IChange objects, which you have to traverse in a foreach loop. Each change object, as far as I see it however, can consist of multiple IFieldDiff objects which you can get as an array when invoking getDiffs on a IChange object.

In each FieldDiff object of the array you can get the field that was changed, here you have to check if you have the status field detected. When invoking [url]=https://almdemo.polarion.com/polarion/sdk/doc/javadoc/com/polarion/platform/persistence/diff/IFieldDiff.html#getAfter--getAfter[/url], I think you have to check it that way in order to see if the work item was set to in progress:

Code: Select all

#if($fieldDiffSelectedInLoop.getAfter().getId() == "in_progress")

Or, If I am wrong and String comparison does not work that way in Velocity, do it this way:

Code: Select all

#if($fieldDiffSelectedInLoop.getAfter().getId().compareTo("in_progress") == 0 )


You need to use getId() in this case because what you get is not just a String but an IStatusOpt object.
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

SaoBit
Posts: 8
Joined: Tue May 12, 2015 8:02 am

Re: Get real starting date of an item

Postby SaoBit » Mon Apr 09, 2018 1:31 pm

To get a larger table with these dates is a performance-killer when using the diffmanager.
It would be better to change the workflow to set your custom field to the correct date.
See Help - Search for "ChangeField".

When there are a lot of Work Items that don't have the field filled properly, try to create a Classic Wiki Page to get the date once and fill the field.

victorien
Posts: 7
Joined: Wed Mar 14, 2018 1:41 pm

Re: Get real starting date of an item

Postby victorien » Thu Apr 12, 2018 10:21 am

Thanks for your replies, I will indeed use the workflow instead, but I will keep diffmanager in mind, it might be useful for some cases.
Thanks a lot !


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 11 guests