It's all about the answers!

Ask a question

How do you assign an owner to children WIs automatically when saving a parent WI?

Taki Nakajo (1.1k2846) | asked Feb 12 '16, 2:32 a.m.
How do you assign an owner to children WIs automatically when saving a parent WI?

Accepted answer

permanent link
Kohji Ohsawa (5951310) | answered Feb 12 '16, 2:52 a.m.
Hi Take-san,

If you are talking about a custom followup action, I am doing like below. It doesn't work for a child WI which is created by a parent and you will need to add more exception handlings, but I think you can use this sample as a start point.

public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException {
        Object data= operation.getOperationData();
        ISaveParameter saveParameter = null;
        if (!(data instanceof ISaveParameter)){
        saveParameter = (ISaveParameter) data;
         if (          (saveParameter.getAdditionalSaveParameters() == null)
                 ((saveParameter.getAdditionalSaveParameters() != null)
           && (!saveParameter.getAdditionalSaveParameters().contains(Recursion)))
        ) {
            IWorkItem parent = (IWorkItem) saveParameter.getNewState();
            IContributorHandle owner = parent.getOwner();
            List<IWorkItemHandle> workItemHandleList = findChildHandle(saveParameter, monitor);
            IWorkItemServer workItemServer = getService(IWorkItemServer.class);
            Iterator<IWorkItemHandle> iter = workItemHandleList.iterator();
            while (iter.hasNext()){
                IWorkItemHandle workItemHandle = (IWorkItemHandle);
                IWorkItem workItem = (IWorkItem) workItemServer.getAuditableCommon().resolveAuditable(workItemHandle, IWorkItem.FULL_PROFILE,
                workItemServer.saveWorkItem3(workItem, null, null, bypass);
    private List<IWorkItemHandle> findChildHandle(ISaveParameter saveParameter,
            IProgressMonitor monitor) throws TeamRepositoryException {
        List<IWorkItemHandle> workItemHandleList = new ArrayList<IWorkItemHandle>();
        List<IReference> references = saveParameter.getNewReferences()
        if (references.isEmpty())
            return workItemHandleList;

        for (IReference reference : references){
            if (reference.isItemReference() && ((IItemReference) reference).getReferencedItem() instanceof IWorkItemHandle) {
                workItemHandleList.add((IWorkItemHandle)((IItemReference) reference).getReferencedItem());
        return workItemHandleList;
Taki Nakajo selected this answer as the correct answer

One other answer

permanent link
Dinesh Kumar B (4.1k413) | answered Feb 12 '16, 3:46 a.m.

Below link shows updating parent, thought this may interest you... :


Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.