Create a Site column in SharePoint Online using Power Automate

Site columns in SharePoint are the reusable column, which we can use in any libraries and list in a SharePoint site and subsites.

In this Power Automate tutorial, we will see how to create a site column in SharePoint Online site using Power Automate. Also, I will show you, how to get the details of a SharePoint site column. Finally, I will show you, how to delete a SharePoint Online site column using Power Automate.

Here we are going to cover the below topics:

  • How to create a SharePoint site column using Power Automate
  • Get/check site column in SharePoint using Power automate
  • Delete a site column from a SharePoint Online site using Power Automate

If you want to create bulk site columns in SharePoint, check out How to create SharePoint site columns from an Excel file in Power Automate?

How to create a SharePoint site column using Power Automate

Here we will see two different ways to create a SharePoint site column using Power Automate.

  1. using SchemaXml in json
  2. using simple JSON code

Now let’s create a SharePoint site column using the first method with Power Automate instant cloud flow.

Method 1: (using SchemaXml)

Step 1: Log in to Power Automate, then click on +Create in the left navigation -> click on Instant Cloud Flow.

Create site column using Power Automate
Create site column using Power Automate

Then provide the flow name, and select Manually trigger flow. Click on Create.

How to Create site column using Power Automate
How to Create site column using Power Automate

Now you can see Manually triggering a flow action is added to the Flow.

Create SharePoint site column using Microsoft Power Automate

Step 2: Create a compose action and rename it like below ‘SchemaXml’ and then in input provide the below schema:

<Field Type="Note" DisplayName="Comments" Description="A Sample description field." Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="MyCustomFields" StaticName="myComment" Name="myComment"></Field>
How to Create SharePoint site column using Power Automate

In the above Scema, we will create a column name Comment but internalColumn name is ‘myComment’. Also, it will create a group i.e. MyCustomFields.

See also  Power Automate Approval Reminder - How to Send

Next, we will use this schema while creating the Site column with the rest API call in Power Automate.

Step 3: Click on the +New step -> select Send an HTTP request to SharePoint action. Then provide the below information:

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Post method as we are creating the SharePoint site.
  • Uri: provide the below uri to create the site column:
_api/web/fields/createfieldasxml
  • Header: Then provide the below header used to do the rest API calls to SharePoint:
{
   "accept": "application/json;odata=verbose",
   "content-type": "application/json;odata=verbose"
}
  • Body: Then provide the below body:
{
  "parameters": {
    "__metadata": { "type": "SP.XmlSchemaFieldCreationInformation" },
    "SchemaXml": '@{outputs('Compose_-_SchemaXml')}'
  }
}
Power automate create site column

Our flow is ready to create a site column in the SharePoint site, we can test it.

Step 4: To test the flow, click on save -> click on the Test icon -> select ‘Manually’ -> click on the Test button -> configure your connector with connection, -> click on Run Flow.

You can see your flow ran successfully.

Power automate create sharepoint site column

In SharePoint site, go to the Site Settings -> under Web design galleries -> click on Site columns. You can see the MyCustomField, under that you can see ‘Multiple lines of text’ column.

Power automate create sharepoint online site column

This is how to create a SharePoint site column using SchemaXml in Power Automate.

Method 2: (using simple JSON code)

For the second method, create a new Power Automate instant cloud flow that will manually trigger, as we have created for the first method.

Then add a new step, and create a new action ‘Send an HTTP request to SharePoint’. Then provide the below information:

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Post method as we are creating the SharePoint site.
  • Uri: provide the below uri to create the site column:
_api/web/fields
  • Headers: Provide the below headers to create Site columns through the rest API call.
{
  " Content-Type": "application/json;odata=verbose"
}
  • Body: Provide the body of the rest API call, which contains the information related to the Site column. Here we are creating a date column i.e. DOB.
{
    "Title": "DOB",
    "FieldTypeKind": 4,
    "Required": false,
    "StaticName": "MyDobColumn",
    "Group": "MyFields",
    "Hidden": false
}
Create site column sharepoint online power automate

Now test the flow Manually, In the Site column page you can see a new group and site column get created like below:

Create site column using power automate

These are the two methods we can create a Site column in SharePoint using Power Automate.

See also  How to Remove line breaks from text in Power Automate?

Get/check site column in SharePoint using Power automate

Here we will see how we can get or check site column is present or not using Power Automate.

For this create an Instant clod flow, and select Manually trigger a flow action. Then add a new action i.e. ‘Send an HTTp request to SharePoint ‘. Provide the below information:

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Get method as we are fetching the site column from SharePoint site.
  • Uri: Provide the below uri to get the site column:
_api/web/fields/GetByInternalNameOrTitle('MyDobColumn')
Create site column using power automate

Now run the flow manually, as site column ‘MyDobColumn’ is available, you can check all the information in the output

Create site column using power automate or microsoft flow

This is how to view details about a particular SharePoint Online site column using Power Automate.

Delete a SharePoint site column using Power Automate

Here we will see how to delete a SharePoint site column using Power Automate.

In the last flow, we fetch the site column from a SharePoint Online site. So, in this, we will use the same flow to delete a SharePoint Online Site column.

So, add a new action “Send an HTTP request to SharePoint”. Then provide the below information.

  • Site address: Provide or select the site address for creating site columns.
  • Method: Select the Post method as we are deleting the site column from the SharePoint site.
  • Uri: Provide the below uri to get the site column:
_api/web/fields/GetByInternalNameOrTitle('MyDobColumn')
  • Header: Provide the Header to delete the Site column required for the rest API.
{
   "accept": "application/json;odata=verbose",
   "content-type": "application/json;odata=verbose",
   "IF-MATCH":"*",
   "X-HTTP-METHOD":"DELETE"
}
Delete SharePoint site column power automate

Now test the Flow, you can see on the Site column page, the DOB column gets deleted from the SharePoint Site column page.

See also  Top 75 SharePoint Online interview questions and answers

This is how to delete a SharePoint Online site column using Power Automate or Microsoft Flow.

Conclusion

In this Power Automate tutorial, we saw how to create a SharePoint site column using a Power Automate rest API call.

Also, we saw how we can get about a particular site column using Power Automate as well as delete a Site column from a SharePoint Online site using Power Automate.

You may like the following Power Automate tutorials:

>