Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

How to create a new SharePoint list column with Power Automate flow

Posted on May 22, 2022May 25, 2022 by Tom

“I’m bored from manually creating columns in a SharePoint list, can I somehow automate it and create a column using Power Automate flow?”


Creating SharePoint columns doesn’t belong among the most entertaining tasks, especially if there’re multiple columns or multiple lists where you must create them. It can so easily turn into lots of annoying mouse clicks to do that. But do you have to do it manually? Wouldn’t it be much better if you could automate the task?

Create the field XML schema

Before you can create a new field, you must compose the field information, e.g. name, what type of field it is, etc. I found this blog post as a good reference for the XML for each of the column types, even though it needs a small change to be used in Power Automate flow. Let’s take an example, a single line of text column:

<Field
    Type="Text"
    DisplayName="Document Title English"
    StaticName="TitleEN"
    Name="TitleEN">
    Description="Document Title in English"
    Required="TRUE"
    EnforceUniqueValues="FALSE"
    Indexed="FALSE"
    MaxLength="255"
    Group="Demo"
    ID="{161ef8f6-e73c-4c56-8a5f-c6a8900f2fc8}"
</Field>

You can see that there’re multiple names for the column. There’s the DisplayName, StaticName and Name. While the StaticName and Name are intended to be that column’s internal name, it’ll actually use the DisplayName. You don’t want that as such internal name would be terrible to work with. Therefore, use the same internal name for all the names – no spaces, no special characters, e.g.

<Field
    Type="Text"
    DisplayName="TitleEN"
    StaticName="TitleEN"
    Name="TitleEN">
    Description="Document Title in English"
    Required="TRUE"
    EnforceUniqueValues="FALSE"
    Indexed="FALSE"
    MaxLength="255"
    Group="Demo"
    ID="{161ef8f6-e73c-4c56-8a5f-c6a8900f2fc8}"
</Field>

Use the XML schema in an HTTP request

You defined the column, now you can create it with an HTTP request to SharePoint.

Method: POST

Uri: _api/web/lists/getByTitle('<listName>')/fields/createfieldasxml

Headers:
{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose"
}

Body:
{
'parameters': {
    '__metadata': {
        'type': 'SP.XmlSchemaFieldCreationInformation'
    },
    'SchemaXml': '<columnXmlDefinition>'
}
}

Note: <…> are placeholders, replace them including the < and >.

Power Automate create SharePoint column

This request will take the column configuration from the XML and use it to create the column in the SharePoint list. But since you had to use the internal name in the XML definition, you should use one more step to rename the column (unless you’re fine keeping the internal name).

Change the column display name

The field can be renamed with another HTTP request to SharePoint. You’ll need the list name, the column internal name (from the XML definition) and the new name.

Method: PATCH

Uri: _api/web/lists/getByTitle('<listName>')/fields/getbytitle('<columnInternalName>')

Headers:
{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "application/json;odata=verbose",
  "IF-MATCH": "*"
}

Body:
{
    '__metadata': {
        'type': 'SP.FieldText'
    },
    'Title': '<newColumnName>'
}

Note: <…> are placeholders, replace them including the < and >.

The request will find the column and change its name to the new value.

Summary

To create a new SharePoint column using Power Automate flow you’ll need three things. Firstly, the XML for the new column with all its settings. Secondly, an HTTP request that’ll take this XML and create the new column according to these instructions. And thirdly, another HTTP request to rename the column to a more user friendly display name.

You could add also one HTTP request in between to add the column to a view.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme