Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to add custom attribute to Work item type definition by using Plain Java API

Please kindly let me know how to add a custom attribute to a Work item type by using Plain Java API.

I have added some custom attributes to a project area by using the following code.

IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);

IProcessItemService processService = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
URI uri = URI.create(projectName.replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea) processService.findProcessArea(uri, null, monitor);
if (projectArea == null) {
throw new InvalidArgumentException("Project area not found.");
}
IProjectArea projectAreaCopy = (IProjectArea) processService.getMutableCopy(projectArea);

        // Specify the work item type ID and the custom attribute details
        String workItemTypeId = WorkItemTypes.TASK;
        String customAttributeId = "customattribute2";
        String customAttributeDisplayName = "CustomAttribute2";
        String customAttributeType = AttributeTypes.SMALL_STRING; 
        
        IAttribute customAttribute = workItemClient.createAttribute(projectAreaCopy, customAttributeId, customAttributeType,customAttributeDisplayName, monitor);
        
However, I can not find how to add these custom attributes to a Work item type.
com.ibm.team.workitem.common.model.IWorkItemType does not have any feature to update work item type definition.

0 votes


Accepted answer

Permanent link

 As far as I can tell, there is no dedicated API to add a custom attribute to the process.  createAttribute creates an attribute on a specific work item. It does not store this information in the process XML. You can debug the rich client platform implementation of Eclipse, how that creates custom attributes, but you will likely not find public API. 

Tadahiro Hara selected this answer as the correct answer

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Nov 05 '23, 11:28 p.m.

Question was seen: 560 times

Last updated: Nov 06 '23, 3:20 a.m.

Confirmation Cancel Confirm