Question

Triggering workflow on a document library with metadata

  • 10 March 2023
  • 4 replies
  • 142 views

Badge +2

Hi ,

I have a document library with some columns that capture some metadata. When a new file is uploaded and metadata is added, I would like to send an email that a new document is uploaded and include the metadata in the email. I would like to send a different email  that the document is revised, if the file is overwritten and updated the metadata. This seems like almost impossible to do with Nintex. I tried enforcing checkout and setting certain columns to required. What is the best way to do this?


4 replies

Userlevel 3
Badge +8

Hi @rythm,

 

So from what I understand, you want to send an email when an item is created and a second email if the item is changed.

One way of doing this is by creating 2 separate list workflows, one that kicks off when a new item is added, and the other if an item is modified:

Another way (which am not 100% sure will work, but I think it should lol) is to have your workflow start when items are added or modified, and use a conditional branch with list columns in your condition to distinguish which items were added and which were modified. For example: 

I'm using the default date/time column that the item was created and the date/time that the item was modified, so if the date/time that the item was modified, is after than the date/time the item was created, then I know that the item was modified and can send a different email.

 

Hope this helps :)

Userlevel 3
Badge +9

Something else I often use if the version number of the document. Check in the library definition how you have set the versioning for this library.

After the first update the document version goes up.

But when it is just default library the version 1.0 goes for a new document. It comes as a text string so you'd have to convert it to decimal for easy conditioning:

 

Otherwise I suggest you keep a boolean field named something like ‘HandledAsNew’ which you update to yes after the first time you've handled this document as new. Be aware of looping when updating an item in a library as this might trigger the same workflow again and again.

Badge +2

Hi,

 

Thank you for your replies. However, my case is slightly different. When we first upload a document, we have to also enter metdata. But the workflow does not wait  until all the metadata is entered and it sends an email saying that a new file is uploaded and one of the metdata dynamic  field values comes back as blank in the email ,…

 

How do I handle this situation?

Userlevel 3
Badge +9

Thanks for explaining your situation a bit more. I believe there is a solution to what you want to do.

If you want to control the upload process including metadata I’d recommend the following:

  1. Create a form that requests all the meta data. This is a separate Form workflow (not a form on the SharePoint library). Create a new workflow with ‘Form’ as the start event.
  2. Design the form
  3. Insert fields for the meta data
  4. Insert a File Upload field
  5. You may limit the file upload to 1 file of a certain max. size and a certain file type.

  6. Apply changes to the form

  7. In the workflow you may use the SharePoint connector action Get Attachment names to get the collection of attachments (just one actually) and then Get attachment by name to store it in a file variable.

  8. Perform an Store a file action to save the file into the library you want. It returns you an object with the ID in the library that you can then use to update the item:

  9. Perform an Update items on the newly create library item to update all the meta data given by the form.

  10. Send the user a nice email.

This is for a new file.

If you include a check if the file already exists, you can send a different email for new or updated files.

Hope this helps.

Feel free to contact me if you need any help if you’d like to implement such a solution.

Reply