It's all about the answers!

Ask a question

set category and typology on a working copy

Elia Gaglio (263) | asked Apr 21 '15, 3:27 a.m.
i'm trying to set category and typology on a working copy but an has been raised during the execution of the code.

This is the piece of code that raises the exception:

            ServiceManagementAutomaticFieldsManagementBean bean = map.get(macroCategoriaLiteral + SEPARATOR + categoriaLiteral + SEPARATOR + sottoCategoriaLiteral);       
            if (bean != null) {
                IWorkItemType workItemType = null;
                for (IWorkItemType iWorkItemType : findWorkItemTypes) {
                    if (iWorkItemType.getDisplayName().equalsIgnoreCase(bean.getTypology())) {
                        workItemType = iWorkItemType;
                //serviceManager.getWiService().findCategoryByNamePath(newStateWi.getProjectArea(), namePath, monitor)
                ICategory correctCategory = null;
                for (ICategory iCategory : categories) {
                    if (iCategory.getName().equalsIgnoreCase(bean.getCompetenceCenter())) {
                        correctCategory = iCategory;
                IWorkItemType findWorkItemType = serviceManager.getWiService().findWorkItemType(newStateWi.getProjectArea(), newStateWi.getWorkItemType(), null);
                IWorkItem workingCopy = (IWorkItem)serviceManager.getWiService().findWorkItemById(newStateWi.getId(), IWorkItem.DEFAULT_PROFILE, null).getWorkingCopy();
                boolean test = workingCopy.isWorkingCopy();
                serviceManager.getWiService().updateWorkItemType(workingCopy, workItemType, findWorkItemType, null);               
                serviceManager.getWiService().saveWorkItem2(workingCopy, saveParameter.getNewReferences(), null);

During the updateWorkItemType() and setCategory() invocation the exception is raised.
Any idea?


Accepted answer

permanent link
Elia Gaglio (263) | answered Apr 22 '15, 3:22 a.m.
The problem was related to the creation of the working copy. In fact using FULL_PROFILE instead of the DEFAULT_PROFILE the code works fine.

Ralph Schoon selected this answer as the correct answer

Your answer

Register or to post your answer.