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

How to get the list of required attributes that needs to be setted by creating a new work item RTC Java API?

Hello,

In my Java client application, I need to create a lot of new Work Items. I have two repositories and several projects area on them, and for each project there are the different fields (attributes) that are required to be set by creating new item. So, here is my question from the topic: is there a way to get list of required attributes from specified project?

Thank you,
Kamil

1

0 votes


Accepted answer

Permanent link
You can find it in the work item common (and server)

IWorkItemCommon.findRequiredAttributes(workItem, workflowAction, monitor)

You can also find the read only attributes there.
Kamil Dudek selected this answer as the correct answer

2 votes

Comments

Thank you for your answer! So, can I get the instance of IWorkItemCommon from server using ITeamRepository.getClientLibrary(Class arg)? Could you also tell me, what is the workflowAction? Maybe this question are silly, but I'm only beginning developing in that API :)

Thanks in advance!
Kamil

Yes, in the Client API you get the client library. In the server API you get the IWorkItemServer with an analog call.

Like in https://rsjazz.wordpress.com/2016/07/15/build-on-state-change-work-item-save-participant/ you use com.ibm.team.repository.service.AbstractService as superclass and then you use getService()


2 other answers

Permanent link

hi kamil,

i dont know, how to get list of required attributes but you can try to read this topic:

https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

its maybe help you...

other way: i have 2 ideas about this topic

1- u can handle error in your java api and set the attribute one by one...

for example:

error message: you can set the summary

if it is set the summary  

i think it is bad idea :)

2- u can list the required fields manuel for each project area (just 1 times) and use this list in your code...

if required attributes changing in time maybe you can try to save the list as xml or config file and read in your java code easyly.

0 votes


Permanent link
Adding a snippet (plain java api)

(IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
String workItemTypeId = ....;
IWorkItemType workItemType = workItemClient.findWorkItemType(projectAreaHandle, workItemTypeId, progressMonitor);
IWorkItemWorkingCopyManager workItemWorkingCopyManager = workItemClient.getWorkItemWorkingCopyManager();
workItemHandle = workItemWorkingCopyManager.connectNew(workItemType, progressMonitor);
WorkItemWorkingCopy workItemWorkingCopy = workItemWorkingCopyManager.getWorkingCopy(workItemHandle);
IWorkItem workItem = workItemWorkingCopy.getWorkItem();
Collection<String> requiredAttributes =  workItemClient.findRequiredAttributes(workItem, null, progressMonitor);
for (String requiredAttribute : requiredAttributes) {
log.trace("requiredAttribute =>" + requiredAttribute + "<=");
}


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
× 457
× 411

Question asked: Jun 15 '15, 7:52 a.m.

Question was seen: 3,734 times

Last updated: Jul 16 '16, 4:49 p.m.

Confirmation Cancel Confirm