check if document in folder has specific text

  • 30 March 2017
  • 3 replies
  • 5 views

Badge +8

Hi Everyone,

I have a weird requirement.  I have a document library that has a folder [test1] inside that folder is document1 and document2.  I need to run a workflow on the folder and see if any document comes back with '2' in the name and if it doesn't, send out an email.  Any suggestions on how I would go about this is appreciated!

Thanks!

Jennifer


3 replies

Userlevel 3
Badge +9

You can't run a workflow on a folder.  You can run it on the list, or the site.  I'd recommend doing a site workflow.  It's a 2 step process.

  1. Find all the documents that match your criteria
  2. Determine if the documents are in the specific folder.

For part 1, use the Query List action to query the library this folder is in.  Make sure to check the box for "Recursive".  This makes it search within folder.  Set your criteria to look for any documents where the Name contains 2.  (or does not contain 2.  I didn't exactly understand your conditions if you want to send out the notification if has 2 or doesn't have 2).  I would return the ID field and create a collection variable to store it.

For part 2, once you have the collection of ID's, you now need to determine if the document is in the specific folder.  Use a For Each to loop through the collection.  For each ID, query the list again for that document, and pull back the URL Path of the document.  You can use a Regular Expression action to remove the file name to get just the path.  Then evaluate that url to see if it matches the path of your folder.  If it does, then you can send out your email.  

Badge +8

Thank you for the quick reply, I am building the workflow now.

Thanks again!
Jennifer

Userlevel 7
Badge +17

Jennifer if you succeed with suggestion from Brendan please do not forget to mark his answer as "Correct" happy.png

Regards,

Tomasz

Reply