Flow: Create SharePoint List Person or Group Fields Using REST API with Power Automate

When you have an existing SharePoint list or if you have created one using the method described in Create SharePoint List REST API with Power Automate, you will then want to populate it with some fields.

There are several FieldTypeKinds, at least 31 and you kind find more information on them at this linkFieldType Members.

In this post, I will cover another commonly used FieldType in SharePoint, the "User" field which creates Person or Group data pulling from Azure Active Directory. I will create 3 of these in order to demonstrate the creation of multiple fields of the same FieldType using a single process.

Here is the complete Flow:

NOTE: There are 2 REST POST calls we will make. 1 that creates the field, one that adds the new field to the default view. I have included both of these within an "Apply to each" to allow us to handle the creation of multiple fields.

Using REST, when you create the new field there is still a requirement to add it to a view. For the purpose of demonstration, we will use the default "All Items" view but you amend to suit if you have a need to do so. We will also do this within the "Apply to each" in order to add each new field to the default view in turn.

As detailed above, start with a button and "Manually trigger a Flow", unless of course you want to adapt this and use a recurrence, HTTP POST or whatever you suits your use case.

Next, I am initialising 2 variables that include the SharePoint Site URL and one for the list name. Again, not required, you could just add them to them in to the "Send an HTTP request to SharePoint" action but this is a little neater and can help for changes in the future.

The Compose below has the name of the 3 x User (Person or Group) fields we are looking to create. We have contained the 3 names within an array to allow the "Apply to each" loop to do the hard work.

createArray(string('Champion'), string('FacilityManager'), string('GeneralManager'))

Create an "Apply to each", the one in this example is called "Apply to each Create Each New Column Person"

Now for the all important REST POST calls, starting with "Send an HTTP request to SharePoint Create List Columns".

Url

_api/web/Lists/getByTitle('@{variables('ListTitle')}')/Fields

Headers

Accept | application/json;odata=verbose

Content-Type | application/json;odata=verbose

Body

Next, let's create "Send an HTTP request to SharePoint Add Column To View".

Url

_api/web/Lists/getByTitle('@{variables('ListTitle')}')/views/GetByTitle('All%20Items')/ViewFields/AddViewField('@{items('Apply_to_each_Create_Each_New_Column_Person')}')

Headers

Accept | application/json;odata=verbose

Content-Type | application/json;odata=verbose

You will now have created a User field in the SharePoint list called "Test12345", see below for an example that shows it is in the list and also a feature of the default view called "All Items"

Thanks for reading, AlanPs1

Do you need assistance building this Flow?

Visit the Get Help section of the Power Automate Community