(SOLVED) Is it possible to change the type of a work item through bulk edit, the API or a Wikipage?

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

(SOLVED) Is it possible to change the type of a work item through bulk edit, the API or a Wikipage?

Postby ALMighty » Fri Apr 27, 2018 9:33 am

Title says it basically all.

I need to change the type of arond 600 work items however...
1) ...In the Polarion Web UI, the "Change type to:" button is not visible when bulk editing
2) ... the API has also not allowed me to change the type of a work item, any work item on which I invoked setType() threw an exception when passing it to the updateWorkItem method of TrackerWebService.
3) Invoking setType in a Wikipage did not do anything. The following code does nothing, either with endTx or commitTx at the end:

Code: Select all

#set($rootLevelQuery = "project.id:$projectID AND id:XYZ-1234" )
#set($sortingParameter = "title") ## for ordering the query result
#set($rootLevelItems = $trackerService.queryWorkItems($rootLevelQuery, $sortingParameter) )
#foreach($rootItem in $rootLevelItems) ## start foreach1
$transactionService.beginTx()
$rootItem.setType( $project.getWorkItemTypeEnum().wrapOption("typeToGO") )
## $transactionService.endTx(false)
$transactionService.commitTx()
#end

It does not even return an error message. However it complains when I omit the transactionService stuff.
What I also had in mind is to the get the necessary type object (of a work item which is of the type to which I want to change the around 600 items) through getType() and then insert this object with setType() in the work items needed but it had the same result.

Hence, which option do I have left? I do not wanna click through 600 items one by one. :evil:
Last edited by ALMighty on Mon May 07, 2018 5:48 pm, edited 1 time in total.
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

PatrickClaus
Posts: 8
Joined: Thu Jan 18, 2018 11:02 am
Location: Frauenauracher Str. 85, 91056 Erlangen

Re: Is it possible to change the type of a work item through bulk edit, the API or a Wikipage?

Postby PatrickClaus » Fri Apr 27, 2018 12:32 pm

This might be a real dirty solution, but do you have any way of doing this edit through SVN search and replace?

I mean, it sounds kind of stupid, but it would be a solution that does not require you to click through each single workitem.

Check out the repository of the project, locate the 600 workitems and change their type via Search and Replace, Notepad++, some other way.
After the change, commit the changes back to the repo, and check if everythings works out for the Custom Fields, Workflow states, Read-Only, form-Config, etc.

I don't know of any other pretty way of doing it, elsewise. Maybe an export and import with different mapping to workitem type is also an option. (Export as certain workitem, import as different workitem after changing xslx Import mapping of the created export file).
Best Regards,
Patrick Claus

External service provider at Valeo Siemens eAutomotive GmbH
Frauenauracher Str. 85
91056 Erlangen, Germany
Mail Address

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

Re: Is it possible to change the type of a work item through bulk edit, the API or a Wikipage?

Postby ALMighty » Mon May 07, 2018 5:43 pm

PatrickClaus wrote:This might be a real dirty solution, but do you have any way of doing this edit through SVN search and replace?


Thanks for the suggestion but I did kind of this. I modified each workitem.xml but this Search and Replace would have not worked for me because these work items were randomly scattered among a 10000-id range (so the work items in question could be anywhere between workitem ID XYZ-1 and XYZ-10000) and only recognizable by having a certain custom field filled or - to be more accurate - this custom field listed in their workitem.xml, because if they no t have a value in this custom field, the field does not show up in the workitem.xml.

What I did however was writing a small Java application that browsed through all work items, checked if that field was there and if yes, it replaced the text content between the <field id="type">-tag and </field>-tag with the ID of the work item type to which I wanted to turn the work item to. IMPORTANT! You also have to modify the status in the XML based on the workflow of the target work item type, otherwise the work item is trapped in a status of the former work item type.

After each workitem.xml was modified, I did then the SVN commit by hand (I think just 3 clicks for committing all modified 1000 items is an effort not worth writing a separate script or method for).

I can't state the code here because it is confidential but I wrote this based on these two tutorials in approx. just 3 hours, you do not need any Polarion SDK Java library for that because you just manipulate XML files:
https://www.mkyong.com/java/how-to-read ... om-parser/
https://www.mkyong.com/java/how-to-modi ... om-parser/
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 5 guests