Articole din această categorie

Power Automate does not offer out of the box actions to manage the Term store, by adding, updating or removing terms.

With experience in doing this task with PowerShell, I did some research and below is one of the solutions that I tested, and it works very well.

 

The scenario.

  1. Create an item in a Master List.
  2. When an item is created, a flow is starting.
  3. Create the item in Term store in a specific Term store group.
  4. If succeeded, update the master list with 'Success' or 'Error' if any issues appear.

 

For this scenario, the requirements are:

  1. A list that contains the Parent set name and the Parent set GUID.
    (TermSets)
  2. A master list, where the admins/users can add the terms which will be created in the Global term store. (Termstore Demo 1)
  3. At least contributor access to the Term store.
     

The entire flow appears like this:

 

Steps in flow.

1. The trigger: WhenItemCreated-SharePointTermStore

 

2. Flow values: few compose actions to get the values used further in the flow.

Compose-ParentTermSetID
@{triggerOutputs()?['body/ParentSetName_x003a__x0020_TermS/Value']

Compose-TermName

@{triggerOutputs()?['body/Title']}

Compose-TermsetGUID

@{triggerOutputs()?['body/TermSet/TermGuid']}

Compose-TermSetLabel

@{triggerOutputs()?['body/TermSet/Label']}

 

3. Send an HTTP request to create the term using the REST API, POST method.

This command in the body, will create the item and also the synonym and the description. 
(The synonym is not mandatory, but wanted to present the possibility to add synonyms.)

The details:

Method: POST

Uri: _api/v2.1/termStore/sets/@{outputs('Compose-ParentTermSetID')}/terms/@{outputs('Compose-TermsetGUID')}/children

Body:

{  
    "labels": [  
        {  
            "name": "@{triggerOutputs()?['body/Title']}",  
            "isDefault": true,  
            "languageTag": "@{triggerOutputs()?['body/Language']}"  
        },
  {    
            "name": "@{triggerOutputs()?['body/Synonyms']}",  
            "isDefault": false,  
            "languageTag": "@{triggerOutputs()?['body/Language']}"  
        }  

    ],  
    "descriptions": [  
        {  
            "description": "@{triggerOutputs()?['body/TermDescription']}",  
            "languageTag": "@{triggerOutputs()?['body/Language']}"  
        }  
    ]  
}   

 

4. UpdateItem-Success
In case of success, in my scenario, I am updating the term in the list with the status of success.

 

5. UpdateItem-Error

In case of error, I am updating the list with the status of error.

For error, the parallel branch will start only if is not a success the previous action.

The Master list is like this:

The Termset column is Managed metadata column, where the user can select the terms where the new values will be added.

ParentSetName is a Lookup column in the TermSets list.

The term will appear in the term store:

Depending on the results, the items in the list will appear like this:

 

Thanks for reading this article!

SharePoint Term store: How to create terms with Power Automate

16 October 2022

EU Wasea 2022.

Hint:

You can remove this information by activating Premium Plan

This website was created for free in WebWave.
You can also create your own free web page without coding.