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 detailsString 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.
com.ibm.team.workitem.common.model.IWorkItemType does not have any feature to update work item type definition.
Accepted answer
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.