Use Power Automate to create a Document Set – The easy way!

I’ve recently been working with improving some workflows which use Document Sets and stumbled into a problem. Online when you search for “Document Sets using Power Automate” you get posts such as:

Now these posts have helped a lot of people but there is one drawback to them and most of the others I can find online. They rely on the use of _vti_bin (sometimes referred to as SP 2010 REST API)

If you don’t know much about the history of VTI go check this out:

It’s pretty vintage now.

The customer I’ve been working with has a handful of SharePoint 2010 workflows we discovered using the SharePoint Modernisation Scanner and we know that these are due for deprecation any time soon. During updating the Document Set workflows and doing some testing, on my first try it broke, a combination of some long days and other weird issues we’re having on the tenant led me down some rabbit holes and a panic that maybe Microsoft also removed the _vti_bin end points too.

They haven’t - it turns out I had a bad slug but it then enabled me to make these simpler solutions, and neither rely on directly sending http requests to the vti_bin API:

Create a document set the easy way:

Yup - that’s all you need to do, find out the Document Set ID from the Document Library – and update a folder’s metadata. You’ll need to specify a manual setting in the ContentTypeId field, but that’s it!

If you’re now asking – that’s great but I want to be able to do that using all variables, well I've got you covered too:

The trigger could be anything you like, e.g. from a selected item in a SharePoint list 

  • NewDocSetName – the actual name of the new Document Set to be created
  • DocumentLibName – the title of the document library where you want the document set to be created
  • DocSetContentTypeId – You need to go into the Library Settings and open the document set content type you’ve added to the list. In the URL when you’ve opened the link to the content type you’ll find the ID, similar to this: 0x0120D5200010BEA7FB30F01740988C0050C9C11D43
  • SitUrl – the Url of the Site/Subsite
  • Get ListItemEntityTypeFullName, you need to send a HTTP request to the list to find out what the entity type name is to be able to change the items metadata
  • This is a “Parse Json” step. I run the flow once (it’ll fail) to then get the output from the step above to use as the schema
  • Creates the folder
  • Set folder as Document Set – I've copied down the important stuff below:
    • Uri: _api/web/lists/GetByTitle('Documents')/items(@{outputs('Create_new_folder')?['body/ID']})
    • Accept: application/json;odata=verbose
    • Content-Type: application/json;odata=verbose
    • X-HTTP-Method: MERGE
    • IF-MATCH: *
    • Body: { '__metadata': { 'type': '@{body('ListItemEntityTypeFullName')?['d']?'ListItemEntityTypeFullName']}' }, 'ContentTypeId':'@{variables('DocSetContentTypeId')}'}
Hope it helps!


Popular posts from this blog

SPOMigration Retrying due to error -2130246326

App Launcher for SharePoint 2013