How to retrieve a list of attachments of workitem
Hi!
How can I retrieve a list of attachments of a workitem programmatically. I know how to add an attachment but I don't know how to retrieve the existing attachments of a existing workitem. Thanks! Marcel. |
3 answers
How can I retrieve a list of attachments of a workitem You would do it using the same IWorkItemReferences class used when adding attachments: IWorkItemReferences references= workingCopy.getReferences(); List<IReference> attachments= references.getReferences(WorkItemEndPoints.ATTACHMENT); for (IReference reference : attachments) { IItemReference attachmentReference= (IItemReference) reference; IAttachmentHandle attachmentHandle= (IAttachmentHandle) attachmentReference.resolve(); } -- Regards, Patrick Jazz Work Item Team |
How can I retrieve a list of attachments of a workitem You would do it using the same IWorkItemReferences class used when adding attachments: IWorkItemReferences references= workingCopy.getReferences(); List<IReference> attachments= references.getReferences(WorkItemEndPoints.ATTACHMENT); for (IReference reference : attachments) { IItemReference attachmentReference= (IItemReference) reference; IAttachmentHandle attachmentHandle= (IAttachmentHandle) attachmentReference.resolve(); } -- Regards, Patrick Jazz Work Item Team Hi Patrick! First of all thanks for your fast help. Perhaps I should post my current code:
But now I have some additional questions: 1. Why do I have to use a working copy of the workitem although I already have a reference to the workitem in my iteration? 2. How can I save the attachments to disk? Do you have any idea? Thanks in advance! Marcel. |
2. How can I save the attachments to disk? Once you have an "IAttachment" instance, you can use a "FileOutputStream" to save the attachment to your disk: IAttachment attachment = ... To retrieve the attachments of a work-item you need a "WorkItemWorkingCopy" instance from the "IWorkItem": ITeamRepository repo = ... Cheers. |
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.