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

How to get a Field name in RTC WorkItem using Java

Assume in Summary Field, user enters some text,
I can fetch the entered value using getHTMLSummary()
But i need the field Name(Summary) in whcih field  it is entered.

Please let me know the code snippet for this.

Also, is there any documentation for server side plugin developement other than
Lab 1 to 6 PDF provided by IBM

Regards
Chandan

0 votes


Accepted answer

Permanent link
 the accepted answer here provides a utility to dump the attribute values of workitems returned from a workitem query

https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes

this will show you the attribute names, and ID as well as value (for most attribute types)
Chandan M B selected this answer as the correct answer

0 votes

Comments

Hello Sam,
Thanks for the answer.


2 other answers

Permanent link
 Hi Chandan,

You can iterate over the custom attributes:

List<IAttributeHandle> customAttributes = workingCopy.getCustomAttributes();
for (IAttributeHandle iAttributeHandle : customAttributes) {
IAttribute attr = this.getItemFromHandle(IAttribute.class, iAttributeHandle, repositoryItemService);
System.out.println("@ATTR: " + attr.getIdentifier());
}
This two are good references about server side plugin developement:

1 vote

Comments

Hi,

IAttribute attr = this.getItemFromHandle(IAttribute.class, iAttributeHandle, itemService);
GetItemFromHandle i think is your custom function. I am getting an error in that line.

Please send me full snippet. Will be useful for me.

That the Summary field is not a custom attribute.
Looping through the custome attribute is not needed i guess.
Can't we get the FieldName directly without looping

Regards
Chandan

 Oh! Sorry... here is the code from the getItemFromHandle:


repositoryService.fetchItem(handle, null)

Actually,
I need basic IBM provided field names like Summary, Description
not customized fields.
I don't have a any customized field


Permanent link
Internal attributes are treated similar to custom attributes. You can look up the ID of the attribute in the process configuration. There are also internal ID's for them which you can get using the code snippets above.

Also see https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/ WorkItemTypeHelper class.
		List builtInAttributeHandles = getWorkItemCommon()
				.findBuiltInAttributes(projectArea, monitor);
		IFetchResult builtIn = fTeamRepository.itemManager()
				.fetchCompleteItemsPermissionAware(builtInAttributeHandles,
						IItemManager.REFRESH, monitor);

		List custAttributeHandles = workItemType
				.getCustomAttributes();

		IFetchResult custom = fTeamRepository.itemManager()
				.fetchCompleteItemsPermissionAware(custAttributeHandles,
						IItemManager.REFRESH, monitor);

		result.appendResultString("Attributes of Work Item type: "
				+ workItemType.getDisplayName() + " Type ID: "
				+ workItemType.getIdentifier());
		result.appendResultString("  Built In Attributes");
		result.appendResultString(printAttributesAndTypes(
				builtIn.getRetrievedItems(), monitor));
		result.appendResultString("  Custom Attributes");
		result.appendResultString(printAttributesAndTypes(
				custom.getRetrievedItems(), monitor));

.................

	private String printAttributesAndTypes(List items,
			IProgressMonitor monitor) {
		String message = "";
		message = message + "\tNumber of attributes: "
				+ new Integer(items.size()).toString() + "\n";
		for (@SuppressWarnings("rawtypes")
		Iterator iterator = items.iterator(); iterator.hasNext();) {
			Object object = iterator.next();
			if (object instanceof IAttribute) {
				IAttribute iAttribute = (IAttribute) object;
				message = message + "\t " + iAttribute.getDisplayName()
						+ " \tID: " + iAttribute.getIdentifier()
						+ " \tValueType: " + iAttribute.getAttributeType()
						+ "\n";
			}
		}
		return message;
	}

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,935
× 411

Question asked: Apr 07 '15, 11:34 p.m.

Question was seen: 6,169 times

Last updated: Apr 09 '15, 2:54 a.m.

Confirmation Cancel Confirm