How to get parent workitem attribute in custom editor presentation (dojo templated widget)
I've created a custom widget for attribute presentation.
In web part (dojo templated widget) I need to get parent workitem attribute. Is there a way to do it? Process Enactment Workshop version 1.3 in Lab 5 says that: "It is not possible to access the relationships of a work item, especially to other work items from the links tab. It is possible to access work item attributes of type work item. This will return the work item handle but will currently not allow to resolve the referenced work item." So it's not clear whether it is possible or not. Maybe it is possible in dojo templated widget via "this.workItem" or similar? Currently I'm using RTC 4.0.4. Maybe in newer versions of jazz there will be any support? |
Accepted answer
Hi Denis,
You can get the links for a given link type from the working copy. You can also update (add or remove) links ofthe working copy. This is not straight forward and not suggested as this is internal and not a public API. This is subject to change.
To get links for a given link type:
this.workingCopy.getValue({path: ["linkTypes", linkType.id, "linkDTOs"], isSource: linkType.isSource, defaultValue: []});
where linkType.id is the identifier of the requested linkType.
This will return an array of objects (if available).
To add a new link for a given link type:
Create an Object and set the following properties
newLink._isNew= true;
newLink.comment="" /*comment for the link*/
newLink.itemId="" /* item id of the linked item" - If the link type is an item link type
newLink.url= "" /* url of the linked item" - If the link type is an url link type
To the array, that you received using get, add this newly created object and set the array into working copy as follows:
this.workingCopy.setValue({path: ["linkTypes", linkType.id, "linkDTOs"], isSource: linkType.isSource, value: array});
In the above code, you need to have the complete information about the link type you are going to access or update. For example, link type id, if the link type is item link type or url link type. If the link type is source or target.
In your case if you are adding a parent link then link type is
parentLinkType= {id: "com.ibm.team.workitem.linktype.parentworkitem", isSource: false}
Parent link type is an item link type.
Note: We are working on providing a cleaner model and API (IWorkItemReferences) in Web for accessing and updating links of a work item. This will let you access, add and remove links very easily as it looks pretty similar to Java API. This will be available from 5.0.1.But there is no access to this model to the external consumers. We will be working on this which is not yet planned.
Also please note that the above code and APIs are internal and subjected to change. So usage of these are at own risk. Hope this information helps you.
Thanks
Sandeep
Denis Maliarevich selected this answer as the correct answer
Comments
Denis Maliarevich
commented Apr 28 '14, 4:49 a.m.
Thanks, Sandeep. So it's not a public API. We will think if it is acceptable for us to use it.
Denis Maliarevich
commented Jun 12 '14, 4:49 a.m.
Hi, Sandeep,
Denis Maliarevich
commented Jun 16 '14, 8:57 a.m.
Guys from IBM answered that "It seems
Denis Maliarevich
commented Jun 16 '14, 8:57 a.m.
But I have managed to get the attribute via OSLC:
|
One other answer
Denis, May I know how are you building this custom widget? Basically I would like to know the API you are using here. And what is the API you are using to get value for a work item attribute.
Since you mentioned you are in web and building custom widget, I am guessing you are using WorkItemProxy for accessing Work Item data. Please let me know if this is correct.
Thanks
Sandeep
Comments
Denis Maliarevich
commented Mar 17 '14, 6:25 a.m.
My widget is based on the article:
Denis Maliarevich
commented Mar 17 '14, 6:27 a.m.
So I need to get parent workitem attribute in web UI, using javascript or dojo.
Denis Maliarevich
commented Apr 26 '14, 4:35 a.m.
Can anybody help me with solving this question?
|
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.