How to Create a Column in SharePoint Online List or Document Library Using Power Automate Flow​

Quickly Using Power Automate Create Column in SharePoint List

No comments

Loading

In this “Power Automate Create Column in SharePoint List” article, we will learn how to create a column in a SharePoint Online list using Power Automate Flow, where we will use the SharePoint REST API and send an HTTP request to the SharePoint Power Automate action. Before getting into the article, let’s understand what a column is in SharePoint.

What is column in SharePoint?

In SharePoint, a column is a fundamental element that represents a specific piece of data within a list, library, or content type. Columns provide a structured way to define and capture various types of information associated with items or documents. They play a crucial role in organizing, categorizing, and enhancing the way data is stored and managed.

Here’s a detailed explanation of columns in SharePoint:

Definition and Purpose:

A column is a named field that defines the type of data that can be entered or displayed for items within a list, library, or content type.
Columns allow you to capture metadata or attributes that provide context, categorization, and additional information about items or documents.

Types of Columns:

SharePoint supports various column types, each designed to accommodate different types of data. Common column types include:

  • Single Line of Text: Stores short text or alphanumeric values.
  • Multiple Line of Text: Stores long text or alphanumeric values.
  • Number: Stores numeric values, with options for integer or decimal values.
  • Choice: Provides predefined options in a dropdown or radio button format.
  • Date and Time: Stores date or date and time values.
  • Person or Group: Allows selection of users or groups from the SharePoint environment.
  • Hyperlink or Picture: Stores URLs or links to images.
  • Lookup: References data from another list.
  • Currency: Stores currency values.
  • Yes/No: Stores Boolean values.
  • Location: Stores the value of Geo Location.
  • Image: Stores image.
  • Managed Metadata: Supports the selection of terms from a term store

Creating and Adding Columns:

Columns can be added during the creation of lists, libraries, or content types.
They can be defined as required or optional, and their data type can be selected based on the intended use.

Metadata and Organization:

Columns contribute to the metadata associated with items or documents, allowing them to be categorized, searched, and filtered effectively. Metadata helps users find, sort, and filter items, enhancing the organization and retrieval of content.

Customization and Validation:

Columns can be customized with default values, validation formulas, and formatting options to ensure consistent and accurate data entry. Custom columns can also be added to document libraries to provide additional metadata for files.

Content Types:

Columns can be associated with content types, which are reusable sets of columns that define the metadata and behavior of items or documents. Content types allow consistent metadata across different lists and libraries.

Integration and Workflows:

Columns are integral to workflows and automation processes in SharePoint. Workflows can be triggered based on column values, enabling automated business processes.

Search and Indexing:

SharePoint’s search and indexing capabilities rely on columns to provide accurate and relevant search results.

Reporting and Views:

Columns are used to create custom views that display specific columns and filter criteria. Views help users visualize data in a way that’s meaningful to them.

Columns in SharePoint enable structured data capture, metadata organization, and enhanced information management. By defining attributes and characteristics of items or documents, columns facilitate efficient categorization, searching, and reporting within the SharePoint environment.

See Also: The column name in SharePoint has three names, such as display name, internal name, and static name. For details, refer to this article. Proven 3 SharePoint column name: Static Name vs. Internal Name vs. Display Name in SharePoint.

Now, let’s get into the main agenda of this article.

Quickly Using Power Automate Create Column in SharePoint List

A column in SharePoint using Power Automate can be created in two ways:

  • Simple Approach (Directly Passing the Field Metadata): Directly Passing the Field Metadata in the Body of the HTTP Request POST Call
  • Complex Approach (XML schema): Get and construct the field XML schema, then pass this schema inside the body parameter of the HTTP request POST Call.

Simple Approach (Directly Passing the Field Metadata): Directly Passing the Field Metadata in the Body of the HTTP Request POST Call

Below is the screenshot of the Send an HTTP request to SharePoint action to create a column using the simple method:

Create column in SharePoint Online list using Power Automate Flow
Create column in SharePoint Online list using Power Automate Flow

Following are the parameters for the above action:

  • Site Address: Your Site URL
  • Method: POST
  • URI: See below:
_api/web/lists/getbyTitle('Your List Title')/fields
  • Headers: See Below:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}
  • Body: See below:
{
 '__metadata': { 'type': 'SP.Field' }, 
'Title':'My Custom Column',
'FieldTypeKind': 2

}

Notes:

  • The body part is the important configuration; here we have just passed two metadata about the column, “Title” and “FieldTypeKind”, but you can pass other metadata as well, like description, required, indexed, staticname, etc.
  • For the FieldTypeKind”, we have passed it as 2, as this indicates a single line of text column. For more details about the FieldTypeKind’s various values, please refer to this MSDN article: FieldType enumeration.
  • For various other metadata about a new column (single line of text type), refer to the below section:

Metadata about Single Line of Text Column in SharePoint Online List

Below is the metadata about a single line of text column with the sample values:

Type="Text"
DisplayName="Your column display name"
Description="Your column description"
Required="TRUE"
EnforceUniqueValues="FALSE"
Indexed="FALSE"
MaxLength="255"
Group="Your column group name"
StaticName="Your column static name"
Name="Your column internal name"

Complex Approach (Create Column in SharePoint List using XML Schema)

It is a two-step process.

Step 1:

Using the below REST API (send an HTTP request to SharePoint) and the the XML schema of an existing column.

Get column schema XML from SharePoint Online list using Power Automate
Get column schema XML from SharePoint Online list using Power Automate

Below are the parameters for the above SchemaXML REST API:

  • Site Address: Your Site URL
  • Method: GET
  • URI: See below:
_api/web/lists/getbyTitle('Your List Title')/fields/getByTitle('Your Column Title')/SchemaXML
  • Headers: See below
{
"Content-Type": "application/json;odata=verbose"
}

Once you execute the above action, you will get the output something like below:

<Field ID=\"Your existing column GUID\" Type=\"Text\" Name=\"YourColumnInternalName\" DisplayName=\"YourColumnDisplayName\" Required=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"YourColumnStaticName\" FromBaseType=\"TRUE\" ColName=\"nvarchar1\" MaxLength=\"255\" Group=\"Test\" Indexed=\"False\" EnforceUniqueValues=\"False\"/>

Step 2:

Copy the column schema XML into a notepad. Update your new column details in the XML. Add an compose data action to your flow and paste the new column XML into that box.

Create XML scehema for new column creation in SharePoint Online list
Create XML schema for new column creation in SharePoint Online list

Notes:

  • For the ID, pass the guid() function, which will create a new guid for the new column. This is very important to update; if you do not pass this, your flow will try to create a column using the existing GUID, which will never succeed, so we must pass a new GUID for the new column.
  • The recommendation is that you should have all types of test columns in your site; if you don’t have them, then get the XML schema for each type of column from your list. Then, use the column XML schema reference when you are creating such types of columns.

Now that we have the new column XML schema, let’s pass this on to the REST API (Send an HTTP request to SharePoint) action.

Create column in SharePoint Online list using Power Automate Flow CreateFieldAsXML
Create column in SharePoint Online list using Power Automate Flow CreateFieldAsXML

Parameters to the above action:

  • Site Address: Your site URL
  • Method: POST
  • URI: See below:
_api/web/lists/getbyTitle('Your List Title')/fields/createfieldasxml
  • Headers: See below:
{
"Content-Type": "application/json;odata=verbose",
"Accept": "application/json;odata=verbose"
}
  • Body: See below:
{
'parameters': {
'__metadata': {
'type': 'SP.XmlSchemaFieldCreationInformation'
},
'SchemaXml': '@{outputs('Compose_|_New_Column_Creation_Schema')}'
}
}

Demo: Create column in SharePoint List Using Power Automate

We have created the below two columns using the Power Automate flow, explained above:

Create column in SharePoint Online list using Power Automate Flow Demo
Create column in SharePoint Online list using Power Automate Flow Demo

Summary: Power Automate Create Column in SharePoint list

Thus, in this article, we have learned about how to create a column in a SharePoint Online list using the Power Automate Send an HTTP request to SharePoint action REST API. And also, we have learned how to get the XML schema from an existing column in SharePoint and how to create a new column using the existing column schema.

 

About Post Author

Do you have a better solution or question on this topic? Please leave a comment