locked
Get list item attachments and just inserted document from document library RRS feed

  • Question

  • Hello Guys,

    I need to get list item attachments and get just inserted document from document library. 

    I thought to write code in item added event for document library.

    When a new document is added to document library, i need to get that document and get list item attachments from a custom list. In my requirement when an item is added into custom list, document was automatically created in the document library with the copy of list fields. Have done this already. 

    Now I need to get the document from library and get the list item and list item attachments.

    Please share your ideas with me as early as possible.

    Cheers,

    Cherry

    Tuesday, September 10, 2013 8:19 PM

Answers

  • Well there are many ways to get documents from a document library that were recently uploaded or modified using SPQuery or Search Queries

    SPQuery - http://msdn.microsoft.com/en-us/library/ms457534.aspx

    Search Query - http://msdn.microsoft.com/en-us/library/sharepoint/dn423226.aspx#bk_QueryAPIs

    Getting list items where attachments were recently uploaded, I think you'd query all the latest modified list items that have attachments and then look at the actual attachment files to see their created date - attachments are stored in the Attachments folder inside the list.

    I'd recommend a timer job instead of an event receiver. If you want reliability, use timer jobs. MS developers create hundreds of timer jobs, and only a handful of event receivers.

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com


    Tuesday, September 10, 2013 8:28 PM

All replies

  • Well there are many ways to get documents from a document library that were recently uploaded or modified using SPQuery or Search Queries

    SPQuery - http://msdn.microsoft.com/en-us/library/ms457534.aspx

    Search Query - http://msdn.microsoft.com/en-us/library/sharepoint/dn423226.aspx#bk_QueryAPIs

    Getting list items where attachments were recently uploaded, I think you'd query all the latest modified list items that have attachments and then look at the actual attachment files to see their created date - attachments are stored in the Attachments folder inside the list.

    I'd recommend a timer job instead of an event receiver. If you want reliability, use timer jobs. MS developers create hundreds of timer jobs, and only a handful of event receivers.

    Please mark my response as an answer if appropriate.
    Learn.SharePoint.com


    Tuesday, September 10, 2013 8:28 PM
  • Thanks for your reply.

    Can you please share working code for me if possible.

    Tuesday, September 10, 2013 8:35 PM