It's all about the answers!

Ask a question

how to call 'Synchronize Attributes' via client code

Stefania Axo (12621513) | asked Mar 16 '11, 7:42 p.m.
I want to be able to call the 'Synchronize Attributes' via code or doing the same thing via code.
how can i do so?
After the process specification changes, the 'Synchronize Attributes' of the work item query result in the RTC Eclipse IDE will get the changes .

thanks in advantage

9 answers

permanent link
Stefania Axo (12621513) | answered Mar 18 '11, 1:24 p.m.
i think this is the code

i will try to use a similar logic


permanent link
Stefania Axo (12621513) | answered Mar 23 '11, 4:26 p.m.
seems to work fine with the
1. WorkItemOperation extension
2. workItemClient.updateWorkItemType(workItem, type, type, null); where old type and new type are the same.

permanent link
SEC Servizi (97122652) | answered Oct 11 '12, 11:05 a.m.
edited Oct 11 '12, 11:10 a.m.
We are trying to use the code below to synchronize attributes on a work-item:
ITeamRepository repo = …
IWorkItem wi = …
IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemType wiType = workItemClient.findWorkItemType(wi.getProjectArea(), wi.getWorkItemType(), null);
IWorkItemWorkingCopyManager workingCopyManager = workItemClient.getWorkItemWorkingCopyManager();
workingCopyManager.connect(wi, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy workingCopy = workingCopyManager.getWorkingCopy(wi);
boolean changed = workItemClient.updateWorkItemType(workingCopy.getWorkItem(), wiType, wiType, null);;
But then no attributes have been synched... Any advice?
By the way, the same snippet code was suggested by a Jazz developer:
Thanks in advance.

permanent link
Stefania Axo (12621513) | answered Oct 11 '12, 2:07 p.m.
to change the single work item
I created a query and synchronize each work item result of the query.

      while (result.hasNext( null ))
         IResolvedResult<IWorkItem> resolved = null );

         IWorkItem workItem = resolved.getItem();

         WorkItemSynchronizeAttributes synchronizeOperation = new WorkItemSynchronizeAttributes(); workItem, null );

WorkItemSynchronizeAttributes  extendis WorkItemOperation
its method execute will do the rest.
   protected void execute( WorkItemWorkingCopy workingCopy,
         IProgressMonitor monitor )
         throws TeamRepositoryException
      IWorkItem workItem = workingCopy.getWorkItem();
      ITeamRepository teamRepository = workingCopy.getTeamRepository();
      IWorkItemClient workItemClient = (IWorkItemClient)teamRepository
            .getClientLibrary( IWorkItemClient.class );

      IWorkItemType type = workItemClient.findWorkItemType( workItem
            .getProjectArea(), workItem.getWorkItemType(), null );
      if (type != null)
         workItemClient.updateWorkItemType( workItem, type, type, null );



permanent link
SEC Servizi (97122652) | answered Oct 12 '12, 10:11 a.m.
edited Oct 12 '12, 10:14 a.m.
Ok, even our code seems to work like a charm.
We got problems when we try to update the project area's process with the new attributes using the code below:
IProcessDefinition processTemplate = ...
IProcessItemService processClient = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IWorkingCopyManager workingCopyManager = processClient.getWorkingCopyManager();
IProcessDefinitionWorkingCopy processTemplateFreshCopy = (IProcessDefinitionWorkingCopy) workingCopyManager.createPrivateWorkingCopy(processTemplate);
final String xml = processTemplateFreshCopy.getProcessSpecification().get();
IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.createPrivateWorkingCopy(prjArea);
IDocument document = prjAreaFreshCopy.getProcessSpecification();
This is a very strange behaviour because the process configuration source in the project area it really contains all the attributes...!

permanent link
Stefania Axo (12621513) | answered Oct 12 '12, 11:01 a.m.

are you trying to change the process configuration based on a new updated template?

this is what i do


IProcessItemService processService = (IProcessItemService)repository.getClientLibrary( IProcessItemService.class );

IWorkingCopyManager workingCopyManager = processService.getWorkingCopyManager();

workingCopyManager.connect( projectArea );

IProcessItemWorkingCopy itemWorkingCopy = workingCopyManager.getWorkingCopy( projectArea );


document.set(xml); null );

permanent link
SEC Servizi (97122652) | answered Oct 12 '12, 11:20 a.m.

Yep, given a template we update all the existing project area with that template.

So, instead of:

IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.createPrivateWorkingCopy(prjArea);

as suggest here:, we have to use:

IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.getWorkingCopy(prjArea);

P.S. Thanks a bunch for you answers, Stefania!

permanent link
Canberk Akduygu (99237271) | answered Nov 27 '12, 5:12 a.m.

I try to synch my workitem to another workitem via server-side code. When I press Save Button, my plugin will synchronize Task WorkItem to Release Workitem. And there are some other controls which happens when a Release Workitem created.
IWorkItemType oldType = wiServer.findWorkItemType(operation.getProcessArea().getProjectArea(),"task", monitor);
IWorkItemType newType = wiServer.findWorkItemType(operation.getProcessArea().getProjectArea(),"com.avea.workItemType.release", monitor);
                        workItemCommon.updateWorkItemType(newWorkItem, newType, oldType, monitor);              

Synchronization worked for the attributes but workflow didnt get synchronized. It says "Uninitialized" And also link type with the other workitems is lost. I can see the my childworkitems but there's no releation information.

Do you have any idea how to solve this problem?

Ralph Schoon commented Nov 27 '12, 6:15 a.m. | edited Nov 27 '12, 6:16 a.m.

I am pretty sure that synchronizing work items is not supposed to solve your scenario. Synchronize attributes is only supposed to add any missing attributes from the type to the work item. If you change the type there is a certain mapping that would need to be done. If the work item has a state literal that is not available in the new type's workflow, I would assume issues. Synchronize won't fix that. You might have to: Change the type, map some attributes such as the state (see and then sync to get new attributes added.

Ralph Schoon commented Nov 27 '12, 6:29 a.m.

On a second thought, if you change the type of the work item and there is no matching state in the new type, the work item gets the new state.

You might want to think about:

  1. Running the query and export the data to CSV
  2. Change the type to the desired type
  3. Run a synchronize attributes
  4. Map the states in the CSV file to the new states and use a CSV import to change the state where needed.

Canberk Akduygu commented Nov 27 '12, 10:54 a.m.

As you said there's no matching state in both workitems but state turns into Uninitilized state or may be I understood your assumption.

We have to trigger that action in the editor when we catch the save event. We dont have the choice to export/import. It's a big burden for a "normal" user to know the state name,etc... Workitem should be turned into another workitem during its lifecycle in my case.

If RTC had a rule which might prevent workitem transformation unless user not press the SYNCH link on the editor, it would be great. If the user dont press SYNCH link, some data get lost. I'd like to automatize that action actually.

Mapping the state programmatically is another issue that I am having difficulties :(

Ralph Schoon commented Nov 27 '12, 10:59 a.m.

You could create an Advisor that prevents from changing the type. For API hints look at, the development Wiki and other posts and links.

permanent link
Ralph Schoon (60.5k33643) | answered Nov 27 '12, 6:10 a.m.
Here is an APP that does it for you:

Ralph Schoon commented Nov 27 '12, 6:11 a.m.

Instead of an expression you can also use a query as described in

Your answer

Register or to post your answer.