cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Create a new column in SharePoint list from Flow

Hello all,

 

So I have pre-existing lists that I would like to automate the process of creating a new column on. Can you automate this process with Microsoft Flow?

 

More Details:

I have about thirty lists that I would like to not have to manually go into and create two new columns, as mulitple sources will continue to create more lists overtime. The photo attached shows the two columns I create highlighted in red ink.Screenshot of ColumnsScreenshot of Columns

All help is appreciated!

 

Update: This link provides great examples for accomplishing this type of thing https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/dn6001...

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

 

Yes need to include the JSON request. Please see below. Here I am creating a new text column called 'Country' with field length 25 under the list called 'aj'.

 

sp2.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

16 REPLIES 16

Hi @Anonymous 

 

Creating a column in a sharepoint list is not supported as a direct action in flow currently. What you can do is, to create the two columns in every list in your sharepoint site, you can invoke the rest api using the "send an http request" to sharepoint action and create those columns. Here is an example of how you can invoke the rest api to create a column:

https://www.c-sharpcorner.com/article/how-to-create-column-in-a-list-using-rest-api-in-sharepoint/

More on SharePoint rest api options: 

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints

 

The flow configuration can be: Manual button trigger -> Get Lists from Sharepoint Action -> Apply to each on the List returned -> send an http request to sharepoint.

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Anonymous
Not applicable

So, I can include non-JSON code into the body of a "Send Https request to Sharepoint" and populate the list with the two newly created columns (ex. pulling code from the link's example)? Or, are you saying I need to use the request to call an outside SharePoint Custom Add-in that is created similar to this: https://www.c-sharpcorner.com/article/how-to-create-column-in-a-list-using-rest-api-in-sharepoint/ to achieve the creation of columns?

 

@yashag2255 

Hi @Anonymous ,

 

Yes need to include the JSON request. Please see below. Here I am creating a new text column called 'Country' with field length 25 under the list called 'aj'.

 

sp2.png

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Hi @Anonymous 

 

You can refer to @abm 's suggestion for the send an HTTP request to sharepoint action. You can variabalise the column names / use the dynamic selector if you want to extract those from elsewhere.  

 

You can get more details on the column types and sending http request to invoke the SharePoint REST API from the URL's that I have shared earlier. 

 

More on column types etc. here: 

https://support.office.com/en-gb/article/list-and-library-column-types-and-options-0d8ddb7b-7dc7-414d-a283-ee9dca891df7

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Tom_Slosse
Memorable Member
Memorable Member

Hey all

 

 

Some more information on the different FieldTypes could come in handy for this one I think 🙂

https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj245640%28v%3doffice.15%...

 

Kind regards

 

Tom Slosse



If this reply has answered your question or solved your issue, please mark this question as answered.

Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up.

Is there any way to make the column visible by default?  The HTTP request worked for me, but the new column is hidden.

Hi

 

Once the column is created you need to execute another HTTP POST

 

http://<sitecollection>/<site>/_api/web/lists(listid)/Views(viewid)/ViewFields/addViewField(strField...

 

https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-visio/jj246043(v%3Doffice.15)

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials
Anonymous
Not applicable

Hi,

 

I am trying the same approach here but with newly added column field as choice type.

Power_Automate_Choice.PNG

 

I manage to get it run successfully with new "Phase" column added:

Power_Automate_Phase.PNG

 

However, it won't update or display in the list:

Power_Automate_Phase2.PNG

 

How do I get it it to display once added with power automate?

Power_Automate_Phase3.PNG

Anonymous
Not applicable

Hi @maxwn5, have you found a solution to display the hidden column by default?

The link shared by @abm is no longer reachable.

Thanks.

Hi @Anonymous 

 

You need to change the view manually.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

.

Hi @Anonymous ,

 

You need to creat a new HTTP request w/ POST method to add this (or all columns creates) to the default view.

 

Try w/ this Uri = _api/web/lists/GetByTitle('YOUR_LIST_NAME')/views/getbytitle('All Items')/ViewFields/AddViewField('YOUR_ColumnName')

 

DAAZEVEDO_0-1620598910385.png

 

How using MS Flow insert data in additional Sharepoint columns?

You need to add the filed "Required": "true/false", to the Json body.

You can refer to this documentation : https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-lists-and-list-items-with-re... .

Amino0
Frequent Visitor

In case someone is still wondering how to achieve this in a single action. 

  1. Use the action "Send an HTTP request to SharePoint".
  2. For Uri, use the API /_api/web/lists(guid'@variables('SiteURL')')/fields/createFieldAsXml
  3. Include in body, "Options": 16. Whereas, this means that this field should be added to default view. More information about this attribute along with other options can be found here.
    Below is a sample with Options 17. Whereas, 17 means add to default view (16) and add to default content type (1).
    Amino0_1-1648218657688.png

     

    {
         "parameters": {
              "SchemaXml": "<Field Name=\"MoreInfo\" Type=\"Note\" DisplayName=\"MoreInfo\" Description=\"More info about the Onboarding Task\" RichText=\"TRUE\" RichTextMode=\"FullHtml\" Required=\"FALSE\" EnforceUniqueValues=\"FALSE\" Indexed=\"FALSE\" Group=\"Onboarding\" StaticName=\"MoreInfo\" ShowInEditForm=\"TRUE\" ShowInNewForm=\"TRUE\" ShowInViewForms=\"TRUE\" ShowInDisplayForm=\"TRUE\" ></Field>",
              "Options": 17
         }
    }


 

@Amino0,
Thank you very much! It was the only thing that worked for me!
And to help the others, in the field "Type", I tested with "Number", "Text" and "Datetime", instead of "Note", and it works like a charm!
Best regards!

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,505)