How to fetch specific field of workitem?
I want to write code to fetch specific field of workitem using client api code. I have workitem id.
I have written code like, workItemClient.findWorkItemById(Integer.parseInt(workitemIdArray[i].trim()), ItemProfile.<IWorkItem>createProfile(ITEM_TYPE, AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(Arrays.asList(new String[] {IWorkItem.CREATION_DATE_PROPERTY, IWorkItem.SUMMARY_PROPERTY,IWorkItem.DESCRIPTION_PROPERTY})), null); After the execution of these lines, result is showing values of all attribute of workitem(Full profile of workitem) instead of specific attribute(which i am expecting). Anyone can suggest on this why it is showing complete values of workitem? and how to get only specific attributes of workitems instead of getting total workitem attributes |
3 answers
Ralph Schoon (63.6k●3●36●46)
| answered Sep 02 '13, 2:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please look at https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ and potentially at https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and other related posts on that blog for code examples for common use cases.
Joshua http://www.joshuabambrick.com/rational/ has also published many examples. More links to examples can be found here too: https://rsjazz.wordpress.com/interesting-links/ Comments
Nilesh Patil
commented Sep 02 '13, 2:35 a.m.
Hi Ralph
|
Ralph Schoon (63.6k●3●36●46)
| answered Sep 02 '13, 2:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can create load profiles. Specific load profiles are used to limit the required data transfer.
The best place to look is IWorkItem for example look at how SMALL_PROFILE is defined: ItemProfile<IWorkItem> SMALL_PROFILE= ItemProfile.<IWorkItem>createProfile(ITEM_TYPE, AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(Arrays.asList(new String[] { PROJECT_AREA_PROPERTY, ID_PROPERTY, TYPE_PROPERTY, SUMMARY_PROPERTY, OWNER_PROPERTY, })); I am not sure you can only load one attribute, I usually use the small profile and just add the one I want. I would try the expression above and only put in the one attribute. I want into it e.g. ItemProfile<IWorkItem> SMALL_PROFILE= ItemProfile.<IWorkItem>createProfile(ITEM_TYPE, AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(Arrays.asList(new String[] { "MY_ATTRIBUTE_ID"})); or use ItemProfile loadProfile = IWorkItem.SMALL_PROFILE.createExtension( Arrays.asList(new String[] { "MY_ATTRIBUTE_ID" })); Maybe I don't understand your question correctly, but that should do the trick. Please note, the work items are cached and I don't know if the small profile is always loaded by default. Work items are also objects which are mapped to the relational database table, so the comparison to SQL only carries so far. Comments
Nilesh Patil
commented Sep 16 '13, 12:26 a.m.
Hi Ralph,
The SMALL_PROFILE is not empty and attachments are no attributes. However, that is the only mechanism I am aware of.
|
Hello
If you load one custom attributem, then all custom attributes are loaded, there is no way to do that. ItemProfile is no aware of single custom attributes.
Hope this help
Amaury
Comments
Ralph Schoon
commented Sep 18 '15, 11:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Is is in disagreement with what I see in the item profiles themselves. They claim - and this is used in the production code as well - to be able to only force loading certain attributes. You can create item profiles for the attributes you want. I have also seen errors that indicate this actually works as described in https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ Item Profiles for Loading.
1
Amaury Quintero
commented Sep 22 '15, 3:44 a.m.
The "customAttributesProperty" is added to the custom profile every time you add a single custom attribute and from this very first moment you have access to all custom attributes, there is no way to have a custom profile with just one attribute. One thing is what in the code you can do and other what really happen behind the scenes. Interesting. Thanks for sharing.
|
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.
Comments
Your code only finds and loads the work item. To get at the attribute you need to get the IAttribute first and then use .getValue(IAttribute) on the work item.