“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?
Get the field XML schema from SharePoint
The easiest way to create a new column is from an example. Create the column one time manually in a list or a document library, depending on where you want to recreate it later. Once the column exists, extract its XML schema with an HTTP request as explained here.
Use the XML schema in an HTTP request
Once you have the schema, you can ‘Send an HTTP request to SharePoint’ to create the column. With this approach it’ll be created 1:1, including all formatting, settings, everything you set in the source column.
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 >.
This request will take the column configuration from the XML and use it to create the column in the SharePoint list. But that’s only 1 column, how do you create multiple columns in a single flow?
Create multiple columns in a list / library
You surely don’t want to start the flow repeatably, always changing the schema to create a new column. It should be just a single flow that’ll run once and create all the required columns.
There’ll be still a repeated step though, the extraction of the columns XML schema. Run the http request for each column and store the output in a text editor, e.g. Visual Studio Code. Each column schema on a new line, separated by comma from the previous one. After that add [ at the beginning and ] at the end to turn it into an array.
In the end it may look as the example below, an array with xml schema for all the columns as the items.
Store it in an array variable. Since it’s now an array, you can loop through it in ‘Apply to each’ and create the columns one by one with the HTTP request above.
That’s it, a simple provisioning flow for new lists / libraries.
Summary
To create a new SharePoint column using Power Automate flow you’ll need just two things. Firstly, the XML for the new column with all its settings, which you can get from an existing column. Secondly, an HTTP request that’ll take this XML and create the new column according to these instructions, let it be just a single column or more of them.
Such approach will not only make it easier to create new lists / libraries, but it’ll allow you to copy / set any configuration on these columns. Even those that are otherwise not accessible, as for example addition of rich text columns to document libraries.
You could add also one HTTP request in between to add the column to a view.
Hi,
Thanks for this solution as it is exactly I was looking for. Just I’m struggle with the Patch method as it returns a 501 error Not implemented.
I have search on the web for any specific solution for this issue, but I have not find any.
Any idea on this ?
Thanks for your feedback,
Jérémie
Hello Coste,
I’d double check the request if it’s exactly as in the article, Not Implemented sounds like an attempt to use some function that doesn’t exist.
Hello Tom!
Could the same steps to change the column display name also apply to the column description?
I just had a thought about using a flow to update the Description to act as a dynamic “input-tip” as to the next expected value in a sequence.
Thank you for all you do!
-Micah
Hello Micah,
you can, just use ‘Description’ instead of ‘Title’ in the HTTP request body.
Hi Tom,
Thanks for this. Works perfectly.
Once the column is created however it defaults as a hidden field. Is there any way for it to be created as an un-hidden column?
– Kieran
Hello Kieran,
it might be something in the list schema, try to get the schema from an existing SP list as explained here: https://tomriha.com/get-schema-for-a-new-sharepoint-column-with-power-automate/
After this column is hidden, not showing in default view. Please let me know the xml properties to unhide. I tried hidden, viewable, display but nothing is working. Its working in new form when i am using displayasnewform properties.
Hello Amit,
check this article, it explains how to get a schema from an existing column – you might find the property in that schema: https://tomriha.com/get-schema-for-a-new-sharepoint-column-with-power-automate/
Any guides on creating a lookup column? It seems it needs to be pointed to the right list and column that needs to be looked up and I can’t seem to nail this.
This looks very useful.
Is there an equivalent for making a new ‘Site Column’ so it can be reused in more than one list?
I bought your HTTP cheat sheet but it doesn’t list one there.