Notify only when someone attaches a file to an item?

  • 7 April 2017
  • 9 replies
  • 11 views

Badge +8

I would like to fire off a notification if ( and only if ) someone attaches a file to an existing item.  The item may already have attachments from creation, I just need to know if someone ADDS an attachment.

I plan to couple this with Vadim's great tutorial on collecting attachment URLs using a UDA to pipe the actual attachment URLs into this notification....

Not sure how to go about doing this.  Perhaps I could use Nintex forms somehow to pass a variable when a file is attached?


9 replies

Badge +8

You can use REST API call in JSON to get the attachment details in the Nintex Form Custom JavaScript. For more details check spservices - Display attachments for each list item - SharePoint Stack Exchange  

Userlevel 4
Badge +11

Hi,

unfortunately I don't think it's possible to know if an attachment as just been added..

I think that you have to store in a field of the item some details about the current attachments, so when the item is modified you workflow runs, it checks if the attachments are the same of the ones listed in your field and if yes, it ends otherwise it could do your custom notification logics.

Giacomo

Badge +8

The check for attachments can be taken care in the workflow setting 'Start when the item is modified' set to conditional as shown below:

201619_pastedImage_1.png

Badge +8

Chaitra, I didn't know this was possible, I think this is my solution, thank you!

Badge +8

Chaitra, I take it back happy.png  This doesn't solve my issue because the check for attachments is only True or False, so the conditional start only fires if there were NO attachments previously and now there are.  It won't fire if someone adds an additional attachment later.

Userlevel 3
Badge +9

Chris Almaguer‌, you can use the GetAttachmentCollection Web service to read the attachments for an item.  I would create a field on my list called "Number Attachments" where you can store the number of attachments an item has.  Then when an item is modified, you can run a workflow that gets the current collection of attachments, and compares it to the number in that field.  If it's different, then you can send your notifications.   Here is a workflow that I set up that accomplishes it. 

201631_pastedImage_1.png

Here is how you setup the Web Service Call.  For the List Name use the List Name from Common Properties, and then the ID number for the current Item.

201635_pastedImage_2.png

Once you get these Web Service Call results, use a Query XML to extract the attachments and put them in a collection variable.  You can then do a count on the collection to determine how many attachments you have.  

201636_pastedImage_3.png

The very last thing you'll need to do is update the Number of Attachments field so that it matches the current number. 

Badge +8

Agree with Brendan Murphy. This will work. 

Badge +8

Thanks Brendan!  This is a complex solution but looks like the only way to go.

Userlevel 3
Badge +9

Complex??  It's only 6 steps. happy.png  If this works, please update the answer as well for others that come along.  Thanks. 

Reply