It's all about the answers!

Ask a question

How to update rank of multiple work items ?

Naveen Arora (3178) | asked May 21 '12, 4:27 p.m.

Is there anyway to massively update the rank of multiple work items? Or is dragging and dropping the work items in the backlog plan the only option?

Can the massive update be done in a programmatic way ? The solution does not have to involve Excel. I will consider any option.


3 answers

permanent link
Ralph Schoon (62.7k33643) | answered May 22 '12, 3:15 a.m.
In general ranking is something manual, to provide a custom order in a plan. So it is a manual process. The attribute value is calculated by the plan.

In 4.0RC1 I was able to rank work items and create a query that displays the coumn "Rank (relative to priority)". The column values look like: priority.literal.l11 O00005

You could try (on a test system) to export to CSV, modify the rank and re-import with update. If that does not work the only chance I see is using the plain java client libraries and try to write a tool that modifies the rank, if possible.

permanent link
Lee Gemma Fu-Sun (6) | answered May 23 '12, 6:14 p.m.
Hi Ralph,

Thanks for the suggestion! I work with Naveen Arora. I tried to update ranks by importing them from Excel, but it did not work in our current RTC version Could you please provide more information about the java client libraries that you mention in your post?


Lee Gemma Fu-Sun
CA technologies
APM Shared Services
Associate Configuration Management Engineer
Tel: +1-650-534-9555
Mobile: +1-415-335-5629

permanent link
Ralph Schoon (62.7k33643) | answered May 24 '12, 2:58 a.m.
Hi Lee,

the article talks about using the plain Java Client Libraries. talks about programmatic work item creation. There is a code example to be used with the plain java client libraries.

If you use that as a starter and modify it you would change the WorkItemInitialization inner class to something like:

private static class WorkItemModification extends WorkItemOperation {

private String fAttributeID;
private Object fValue;

public WorkItemModification(String attributeID, Object value) {
super("Initializing Work Item");

protected void execute(WorkItemWorkingCopy workingCopy,
IProgressMonitor monitor) throws TeamRepositoryException {
IWorkItem workItem = workingCopy.getWorkItem();
ITeamRepository teamRepository = (ITeamRepository)workItem.getOrigin();
IWorkItemClient workItemClient= (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

IAttribute attribute = workItemClient.findAttribute(workItem.getProjectArea(),
fAttributeID, null);
workItem.setValue(attribute, fValue);

And call it like this:

int id = new Integer(idString).intValue();
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.SMALL_PROFILE, null);
WorkItemModification operation = new WorkItemModification("anAttributeID","someValue");, null);

I have not tested this code!
You need to look up the attribute ID for RankByPriority (if it exists as attribute), there is no direct setter.

Your answer

Register or to post your answer.