Batch Field Creation using Power Automate
  1. Introduction and Video
  2. Create Flow and Add Input Parameters
  3. Add Variables and Loop
  4. Single line of text
  5. Multiple lines plain text
  6. Multiple lines rich text
  7. Choice
  8. Number
  9. Currency
  10. Date
  11. Yes/No
  12. Person
  13. Hyperlink
  14. Image
  15. Summary

1. Introduction and Video


This guide explains how to create a Power Automate workflow which can generate a batch of fields for any SharePoint list or library.

It is recommended to begin by watching the video before building your Flow using the steps below.

You will be creating a workflow that can be reused any time you want to create a batch of SharePoint fields.

Required for this training

  • Basic Experience using Power Automate
  • SharePoint Admin permissions

Training Content


2. Create Flow and Add Input Parameters

Start by creating a new Instant Cloud Flow named "Make SP List Fields" (or similar) and select the Manually trigger a flow option then click Create.


Turn off "New designer" and close Copilot:


Expand the first Flow block then add 8 inputs as defined below.

Note that you can set whether a field is required by clicking on the ... to the right of the field.


1. Add a required text input named List URL using the description "Paste the list URL".


2. Add a required text input named Field Type using the description "Select field type". Use the Add a drop-down list of options setting to add the choices shown.





Copy and paste these options:

Single line of text
Multiple lines plain text
Multiple lines rich text
Choice
Number
Currency
Date
Yes/No
Person
Hyperlink
Image

3. Add a required text input named Field Names using the description "CSV field names with no spaces". (A Comma Separated Values set of fields will be provided.)


4. Add a required number input named Field Count using the description "How many fields".


5. Add a required text input named Required using the description "Select false or true". Use the Add a drop-down list of options setting to add the choices "false" and "true".


6. Add an optional text input named Default using the description "Optionally provide a default value".


7. Add an optional text input named Choices CSV using the description "If choice field, provide choices". (A Comma Separated Values set of choices will be provided.)


8. Add an optional text input named Description using the description "Optionally provide a description".


The full set of inputs should look like this:



3. Add Variables and Create Loop

Add a new Compose action renaming it to "Compose Site Address". Use the Add Dynamic Content option, select Expression and use this code snippet:

substring(triggerBody()['text'],0,indexOf(triggerBody()['text'],'Lists/'))


This will parse the site address for later reference in the workflow.

Add a second Compose action renaming it to "Compose List Name". Use the Add Dynamic Content option, select Expression and use this code snippet:

replace(last(split(triggerBody()['text'],'/Lists/')),'/','')


This will parse the list name for later reference in the workflow.

Add an Initialize variable action renaming it to "Initialize intLoopCount". Name the variable "intLoopCount", use Type of "Integer" and Value set to "0":


Add an Initialize variable action renaming it to "Initialize intFieldIndex". Name the variable "intFieldIndex", use Type of "Integer" and Value set to "0":


This will be used in a loop based on the number of fields to be created.

Add a Do until loop referencing the intLoopCount variable and referencing the Field Count input as shown.


Inside the loop block, add an Increment variable action which will be at the top of the loop to increment intLoopCount by 1 for each loop.


Directly after the increment variable block, add a Set variable action to set the intFieldIndex to 1 less than the intLoopCount variable.


Use this code snippet for the value: sub(variables('intLoopCount'),1)

Now we are ready to start creating SharePoint fields!


4. Single line of text

Inside the Do until block, add a new condition to check for Field Type of Single line of text.





In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldText"
},
"FieldTypeKind": 2,
"Title": "",
"Required": "",
"DefaultValue": "",
"Description": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, DefaultValue, Description as shown.

Test the workflow by running it to create a set of text fields before moving on to the next step.


5. Multiple lines plain text

Inside the Do until block, add a new condition to check for Field Type of Multiple lines plain text.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldMultiLineText"
},
"FieldTypeKind": 3,
"Title": "",
"Required": "",
"Description": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required and Description as shown.

Test the workflow by running it to create a set of multi line plain text fields before moving on to the next step.


5. Multiple lines rich text

Inside the Do until block, add a new condition to check for Field Type of Multiple lines rich text.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldMultiLineText"
},
"FieldTypeKind": 3,
"Title": "",
"Required": "",
"RichText": "true",
"Description": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required and Description as shown.

Test the workflow by running it to create a set of multi line rich text fields before moving on to the next step.


6. Choice

Inside the Do until block, add a new condition to check for Field Type of Choice.


In the Yes branch, begin by adding a Compose action named "Compose Choices" with this code:

concat('"',replace(CHOICES-CSV-INPUT,',','","'),'"')

Replace "CHOICES-CSV-INPUT" with the Choices CSV input reference.

Next, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldChoice"
},
"FieldTypeKind": 6,
"Title": "",
"Required": "",
"DefaultValue": "",
"Description": "",
"Choices": {
"__metadata": {"type": "Collection(Edm.String)"},
"results": []
}
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

For results (Marked "D") reference the Compose Choices option above.

Last, add input references for Required, DefaultValue, Description as shown.

Test the workflow by running it to create a set of choice fields before moving on to the next step.


8. Number

Inside the Do until block, add a new condition to check for Field Type of Number.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldNumber"
},
"FieldTypeKind": 9,
"Title": "",
"Required": "",
"Description": "",
"DefaultValue": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, Description, DefaultValue as shown.

Test the workflow by running it to create a set of number fields before moving on to the next step.


9. Currency

Inside the Do until block, add a new condition to check for Field Type of Currency.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldCurrency"
},
"FieldTypeKind": 10,
"Title": "",
"Required": "",
"Description": "",
"DefaultValue": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, Description, DefaultValue as shown.

Test the workflow by running it to create a set of currency fields before moving on to the next step.


10. Date

Inside the Do until block, add a new condition to check for Field Type of Date.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldDateTime"
},
"FieldTypeKind": 4,
"Title": "",
"Required": "",
"Description": "",
"DefaultValue": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, Description, DefaultValue as shown.

Test the workflow by running it to create a set of date fields before moving on to the next step.


11. Yes/No

Inside the Do until block, add a new condition to check for Field Type of Yes/No.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.Field"
},
"FieldTypeKind": 8,
"Title": "",
"Description": "",
"DefaultValue": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Description, DefaultValue as shown.

Test the workflow by running it to create a set of Yes/No fields before moving on to the next step.


12. Person

Inside the Do until block, add a new condition to check for Field Type of Person.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldUser"
},
"FieldTypeKind": 20,
"Title": "",
"Required": "",
"Description": "",
"DefaultValue": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, Description, DefaultValue as shown.

Test the workflow by running it to create a set of Person fields before moving on to the next step.


13. Hyperlink

Inside the Do until block, add a new condition to check for Field Type of Hyperlink.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Headers add a key for content-type with the code application/json;odata=verbose

For Body start with this code snippet:

{
"__metadata": {
"type": "SP.FieldUrl"
},
"FieldTypeKind": 11,
"Title": "",
"Required": "",
"Description": ""
}

For Title (Marked "C") use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Last, add input references for Required, Description as shown.

Test the workflow by running it to create a set of Hyperlink fields before moving on to the next step.


14. Image

Inside the Do until block, add a new condition to check for Field Type of Image.


In the Yes branch, add a new Send an HTTP request to SharePoint action as shown.

Carefully reference the code instructions as described:

For Site Address (Marked "A") use the Compose Site Address reference.

For URI (Marked "B") use this code snippet _api/web/lists/GetByTitle('COMPOSE-LIST-NAME')/fields/CreateFieldAsXml where COMPOSE-LIST-NAME is replaced with the Compose List Name reference.

For Body start with this code snippet:

{
"parameters": {
"SchemaXml": "<Field DisplayName='SNIPPET' Format='Thumbnail' IsModern='TRUE' Name='SNIPPET' Title='SNIPPET' Type='Thumbnail'></Field>"
}
}

For the SchemaXml code areas marked SNIPPET use this code snippet:

split(FIELD-NAMES-INPUT,',')[variables('intFieldIndex')]

Replace "FIELD-NAMES-INPUT" with the Field Names input reference.

Test the workflow by running it to create a set of Iamge fields before moving on to the next step.


15. Summary

Manually creating a large number of SharePoint fields can be time consuming. This workflow provides a tool in which a SharePoint Administrator or developer can generate a large set of fields more efficiently saving time and speeding up development.

There are methods to generate fields using Powershell which are also efficient, but these require code updates each time a new set of fields is to be created.

Additional enhancements can be added to this workflow if you wish to accomodate for other field types or additional field properties. Adjust the input parameters and workflow accordingly.

Additional resources: