Setting Managed Metadata Columns via Power Automate
Scenario
When a Microsoft Form is filled out, we have choice menus that correlate to items in a Managed Metadata column. The Microsoft Form returns the text value - we cannot setup a key/value pair that would make this easier.
Format of the value
To set a Managed Metadata column via Power Automate, the value must be in the format of Term Label|Term Guid.
Without this knowledge, it isn't immediately apparent from error messages what the correct format should be.
Resolution
Query the SharePoint Online API by using the Send an HTTP request to SharePoint action. You will need to know your Term Set Id, which you can retrieve from the Term Store section of the SharePoint Admin Center.
The Uri to specify in the action will be: _api/v2.1/termStore/termSets/{termSetId}/terms?filter=labels/any(a:%20a/name%20eq%20%27{nameOfTerm}%27).
Substitute {termSetId} with the Term Set Id you retrieved earlier.
Substitute {nameOfTerm} with the name of the term you want to look up.
The API will return a response that should look like this:
{
"@odata.context": "https://{yourSharePointPrefix}.sharepoint.com/_api/v2.1/$metadata#termStores('root')/termSets('{termSetId}')/terms",
"value": [
{
"id": "{redacted}",
"isDeprecated": false,
"childrenCount": 0,
"createdDateTime": "2024-01-01T21:02:01.343Z",
"lastModifiedDateTime": "2024-01-01T21:02:01.343Z",
"labels": [
{
"name": "{nameOfTermm}",
"isDefault": true,
"languageTag": "en-US"
}
],
"descriptions": [],
"isAvailableForTagging": [
{
"setId": "{redacted}",
"isAvailable": true
}
]
}
]
}To extract the name from the label (and the below assumes there is only one label), use the following and save it to a variable, or use it directly in your next step:
You'll also need the Id:
Then build the term label by concatenating the first value, then a pipe character (|) and then the second value. This can be stored in a variable, or used directly in a future step.
Last updated