Why?
Managed Metadata columns are special and those that allow multiple values are even more special. Since there are no out-of-the-box Microsoft Flow actions (yet) to update Document Sets, we will use the Old school Send an HTTP request to SharePoint.
What?
This post will be a deep dive for updating Managed Metadata with a multi value select setting using the Send an HTTP request to SharePoint action of Microsoft Flow. Much was already explained in the previous post: https://knowhere365.space/update-managed-metadata-column-of-a-document-set-through-microsoft-flow/ so make sure that you read the context and other related posts first.
How?
So you already have a site with a library in which you have added your Document set content type and there are some Document sets created in this library. In my example I want to update the Document Set immediately after creation (you cannot create a document set and update properties of it within the same HTTP call) but because one of the columns I want to update is a Managed Metadata column which allows multiple values to be selected, we need to prepare some things.
1) I named this Managed Metadata column MM_BacklogItemCategory and this column allows multiple values. We need to get the InternalName of the hidden extra column you get with Managed Metadata (see my linked post above on updating single value Managed Metadata through Microsoft Flow for more explanation):
The code for the call:
_api/web/lists(guid'@{variables('varListGUID')}')/Fields/GetByTitle('@{variables('varMM_BacklogItemCategory')}_0')
2) Then we use a part of the response and store it in a variable:
The code for this variable:
@{body('Send_an_HTTP_request_to_SharePoint_-_InternalNameMM_BacklogItemCategoryHidden')['d']['InternalName']}
3) Because the column allows multiple values the data is stored as an array and any dynamic information of the column we use from the triggering item with the same column(s) will therefore be placed in an Apply to each Step. We will create a string variable to store all the selected values: varMM_BacklogItemCategorySelected. The syntax we need is pretty precise so make sure to check the codes very accurately:
Notice the semicolon ; after the Append to string action.
4) Then we can finally extend the body of the update request:
The snippet of code in the body that is relevant for this post:
"@{variables('varMM_BacklogItemCategoryHiddenInternalName')}":"@{variables('varMM_BacklogItemCategorySelected')}"
Now the selected values of the triggering item will update the new multi select values of the Document Set ✔
I have been using this method since October 2019, but starting in May 2020 the managed meta data values fail to get set with no error being thrown. Nothing has changed in the SharePoint list. Are you still able to set the values using this method?
Hi Paige,
I just did a trigger a run of a Flow, I have not touched in years and it still seems to be working:
HTTP post properties:
Uri
_api/web/lists(guid’d4969af7-c0ee-4961-ad93-b26d8f19dfc5′)/items(197)
Headers
{
“Content-Type”: @{variables(‘varAcceptHeaderString’)},
“Accept”: @{variables(‘varAcceptHeaderString’)},
“X-HTTP-METHOD”: “MERGE”,
“If-Match”: “*”
}
Body
{
“__metadata”:{
“type”:”@{variables(‘varListItemEntityTypeFullName’)}”
},
“DocumentSetDescription”:”Set created by : @{triggerBody()?[‘Author’]?[‘DisplayName’]}”,
“@{variables(‘varMM_BacklogItemStatusHiddenInternalName’)}”:”@{triggerBody()?[‘MM_BacklogItemStatus’]?[‘Value’]}”,
“@{variables(‘varMM_BacklogItemCategoryHiddenInternalName’)}”:”@{variables(‘varMM_BacklogItemCategorySelected’)}”
}
Hey guys.
I’m having the same problem as Paige, where I used to set the value of my managed metadata colums using
“HiddenInternalCilumnName”:”SelectedTermSetValue|TermSetGUID”
This worked fine a month or two ago but suddenly stopped working without trhrowing any error. Any ideas for a workaround?
Cheers,