Updating SharePoint Online Document Set in Microsoft Flow (including Taxonomy Field)

This is a follow up from my previous post on Creating SharePoint Online Document Set in Microsoft Flow.

We’ve created the document set, and now we want to update some of the properties for the document set, one of which is a single value taxonomy field.

Assuming add-in only authentication has been set up and the access token has been obtained with a HTTP action and parsed into JSON, as per the previous blog post.

We now have actions after creating our document set to update the document set.

MS Flow Update Doc Set - Overview.png

Step 1: HTTP – Create Document Set

This is the final step in the previous blog post where we use a HTTP action to call the SharePoint REST API to create a document set in a SharePoint document library.

Step 2: Parse JSON – Document Set

MS Flow Update Doc Set - Parse JSON Doc Set.png

We use the Parse JSON action to convert the body response from the Create Document Set HTTP call into a JSON object. Our goal here is to simply get the ID for the newly created document set.

Step 3: HTTP – Update Document Set
MS Flow Update Doc Set - Update Doc Set.png

Now we use a HTTP Post to update the document set. Notice that we’re not using the Folder REST API, because we’re updating custom fields that are outside the bounds of SP.Folder fields. We Post to <site_collection_url>/<site_url>/_api/web/lists/getbytitle(‘<list_name>’)/items(<item_id>), using the full site collection and web url to the target list, getting it by its name, and setting <item_id> to the document set item ID we can get from the Parsed JSON object above.

Authorization token is set the Bearer <access_token> based on the token we would have previously obtained. X-HTTP-METHOD is set to MERGE to perform an update, and If-Match is just set to “*” for simplicity, although you can try and get the etag from the parsed JSON above as well.

The Body shows the JSON required to perform update on various field types. First and foremost, we need to set the __metadata type to SP.Data.<list_name>Item, where <list_name> is the name of the list you’re updating to. In this example, the list name was Documents, so we use SP.Data.DocumentsItem. If the list name is “CustomListName”, you will set type to SP.Data.CustomListNameItem.

Setting text and number fields are straightforward, just set the JSON key/values as required.

Lookup fields and multi lookup fields are interesting. We need to set the key value <lookup_field_internal_name>Id. So for the example above, we have a lookup field with internal name “LookupField”, and a multi lookup field with internal name “MultiLookupField”. See how we’re using the JSON key values of “LookupFieldId” and “MultiLookupFieldId” to set the lookup IDs, whether a single or an array of integers.

To set a single value taxonomy field, we set it to a custom JSON object that has 2 keys, TermGuid and WssId. TermGuid is set to the Unique Identifier of the term you want to set to in your term store. WssId always needs to be set to -1. If it does not exist, the taxonomy field update won’t work. There is an optional Label key you can set as well, but it makes no difference as the update will pull the term’s name based on the TermGuid.

One thing to note is that we supposedly can’t update multi value taxonomy fields using the Rest API. Have not experimented on this myself, but may update this in the future if I get around to it.

Update 3/09/2018: So updating multi value taxonomy fields are possible, but quite convoluted. Thanks to https://www.aerieconsulting.com/blog/update-using-rest-to-update-a-multi-value-taxonomy-field-in-sharepoint for outlining how it can be done. Below is a screenshot on how it can be set up in Flow, where lfc34abda35f47c490ba3073880515cb is the StaticName for the Note field created to store data for a multi-value taxonomy field in my example.

MS Flow Update Doc Set - Update Multi Tax

4 thoughts on “Updating SharePoint Online Document Set in Microsoft Flow (including Taxonomy Field)

  1. Great two Document Set tutorials! Thanks a lot. It was my first time set up a Flow and it went well.
    There is only one question remaining: It is possible that the taxonomy field update no longer work? It displays the error: “A collection was found without the ‘results’ property. In OData, each collection must be represented as a JSON object with a property ‘results’.” I checked my script several times and even tried other tutorials and tips but can’t fix it. 😦


    • Hi Ingrid. I have a feeling the field you’re trying to set is a taxonomy field that allows multiple values. I have updated the post to include an example on how we can set the values for multi-value taxonomy fields, hopefully this will help you out. Cheers.


      • Hi Yi Chiun Lee, yes you’re right! It is a multivalue taxonomy field. I can’t believe that it was such an obvious error… sorry for that. I’ll test you’re multivalue solution as soon as possible. Thanks in advance 🙂


  2. Pingback: Microsoft Flow – Create a Document Set « Karine Bosch’s Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s