2

For a client I'm looking at the following case:

They have all sorts of documents within a document library grouped into folders (multiple levels deep). If a folder doesn't contain a document, the process owner knows that something is wrong since it's not complete. They want to be able to manually start a workflow to check a particular folder for completeness. If it's empty an email must be send with the name of the folder.

I was thinking of using SharePoint Online 2013 workflow however there is no action available to check if a folder is empty or not. So my second thought was using a webservice to do it for me, but I need some guidance on how to do that.

  • Can this be done by leveraging the default web services from SP2013 Online?
  • How can I check if a folder is empty?

I am not a programmer, but I know how to write some code. Any suggestions are welcome.

Thanks, Kevin

1

Yes use SharePoint Rest Services and then calling:

   https://<weburl>/_api/Web/GetFolderByServerRelativeUrl('</sites/site/subsite/library>')/Folders

Just loop through all the results and when ItemCount = 0 and Name of the folder is not equal to Forms(default in every library) send out an email.

It does not list out the subfolders. Still thinking about a proper solution for getting all of the sub folders.

Refrences how to apply in workflows:

http://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/

2

It could be done by leveraging SharePoint REST services.

In SharePoint 2013 workflows was introduced a new action named Call HTTP Web Service. This action is flexible enough to make requests to a variety web services including SharePoint REST service.

The following REST request demonstrates how to determine whether Folder contains items:

/_api/Web/GetFolderByServerRelativeUrl('/[web]/[list]/[folder]')?$select=ItemCount

Note: the query returns the count of items (File or Folder type) stored in the specified folder.

References

  • 1
    Thanks for your answer. Looks good. I will try that approach! – KevinvG Oct 13 '14 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.