Work item attachment links
Hi,
I've written code to add an attachment to a work item using only client side code. As written the, code correctly attaches a file to a work item and it's visible in the GUI when viewing the Links tab in the work item. The issue that I'm having is that if I query the work item and have the Attachments field visible in the query results, the attachment does not show up in the work item list view. Here's the code I'm using to create the link once I save the attachment to the server:
It seems that I'm missing additional back end links, but I'm not sure if I am or if there's something else going on here. Any thoughts would be appreciated. Thanks in advance! Steve |
8 answers
I don't see how to get Attachments as a result field in the query result..
Sam |
I don't see how to get Attachments as a result field in the query result.. Hi Sam, It took a bit of digging before I got to the attachment too. To get to the attachment, you first have to get a working copy of the work item, then you can find any references to the attachment endpoints. Once you have the references to the attachment, you can generate an attachment handle, and then get at the attachment itself. See my code below. You'll notice that I write some file information out to a simple text file (the writer.append lines) so that I can keep track of the files to push them back into work items at a later time.
|
this is the sentence I am trying to figure out
The issue that I'm having is that if I query the work item and have the Attachments field visible in the query results, the attachment does not show up in the work item list view. is this a standard query, or some custom code u wrote.. I don't know what 'workitem list view', means.. If I use the standard approach for building queries, which produces a list, I don't find an option to add the attachments as part of that list. Sam |
this is the sentence I am trying to figure out The issue that I'm having is that if I query the work item and have the Attachments field visible in the query results, the attachment does not show up in the work item list view. is this a standard query, or some custom code u wrote.. I don't know what 'workitem list view', means.. If I use the standard approach for building queries, which produces a list, I don't find an option to add the attachments as part of that list. Sam I misunderstood your question. When you build the work item query in the UI, under the results layout tab, you can add the Attachments column and see what attachments are associated with a work item. |
I found out the error in the code that was causing the missing attachment in the query. When creating the link in the first code I pasted above (linkAttachment method), I had reversed the parent-child relationship in the following line of code:
Parent item (the work item) is first, child item (the attachment) is second. The links are created correctly and the attachment now shows in the work item query listing correctly. |
This looks like Java code. What is the library used for talking to the RTC server, an SDK?
|
Yes, The SDK. See the RTC product downloads.
Note that there are three kits
plain java (client only)
SDK server side
And build system (for running builds)
Sam
|
I tried the code posted in this thread and it is working fine, thanks, but there's a little "bug": The file appears without name at the canvas "Attachments". Is there something I can do to fix it?
|
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.