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
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
Accepted answer
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)
2 other answers
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:
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
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.
Also see https://rsjazz.wordpress.com/2015/02/27/a-rtc-workitem-command-line-version-2-2/ WorkItemTypeHelper class.
ListbuiltInAttributeHandles = 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; }