Using script or web service - how to get all attachments


Question posted 9/22/10 by Russell I
Details:

Hi everyone,
We are using SBM to collect some Demand Management information and approvals. This includes attachments. Ultimately, this data will be sent over to our PPM tool (not Mariner). I have this part done in a simple .NET program just fine. Now I need to tackle the attachments.
I understand that the attachments are tracked in the TS_ATTACHMENTS table. From a scripting point of view, I understand how to read the table and get a single attachment's data, but I'm at a loss as to how to find all of the attachments for an item, and then how to go through each one to get the info from the row. Does anyone have any advice or sample code for this?
I also understand that there is a web service call (method) that I might be able to utilize - GetFileAttachment. I've not used web services yet in SBM. Any guidance here on how to set up this web service call and to use it would be great!
Thanks!


  • Comment posted 9/23/10 by Tom Burnell

    Hi,
    Each entry in the Attachments table has the TS_CASEID field which identifies the owning item, so you could query the table with a "TS_CASEID = <your item Id>" where clause (you'd also probably want to limit it by TS_TYPE to only get file attachments) should return the list of all attachments.
    In Mashup Script, you'd do something like:

    itemId = Shell.Item.GetId()


    whereClause = "TS_CASEID="

  • Comment posted 9/23/10 by Russell I

    Tom, what you posted is EXACTLY what I need! Thanks a ton! I've already had a chance to test it, and it work great.
    In my original post I was just wondering whether processing the attachments would be better accomplished in script or a web service. The script solution actually works better for me in this instance.


  • Comment posted 10/1/10 by Olivier Salmon

    Hi Russell,
    I know you have your response, but in the future if you need more information regarding web services and attachments, you can check my blog as I wrote a couples of articles: http://www.geekmindsthinkalike.com/
    And if you decide to move to PPM, I have an article talking about the SBM / PPM integration ;-)