Skip to main content

How to Set a Minimum and Maximum Value for a SharePoint Number Column with the REST API in Power Automate

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A number column can refuse values outside a range, such as a score below 0 or above 100. When a flow creates the column with the REST API, two attributes in its XML, Min and Max, set that range, and SharePoint enforces it in the item form.

Syntax​

The column is one Field element, sent to createfieldasxml with Send an HTTP request to SharePoint. How to Add a Column to a SharePoint List with CreateFieldAsXml explains the request; only the XML changes here:

Number column with a range: general form
<Field Type='Number' Name='<internal name>' StaticName='<internal name>' DisplayName='<display name>' Description='<description>' Decimals='<places>' Min='<lowest>' Max='<highest>' Required='TRUE' />

From Microsoft's Field element reference:

  • Type='Number': a number column. The reference lists Decimals, Min and Max among the attributes a number column can use.
  • Min='<lowest>': the minimum value allowed for the field.
  • Max='<highest>': the maximum value allowed for the field.
  • Decimals='<places>' (optional): the number of decimals to display. It sets how the number shows, such as 0 for whole numbers.
  • Required='TRUE' (optional): the column must have a value.

You can set Min alone, Max alone, or both. Each is a plain number in quotes, such as Min='0'.

The Example​

A blank list called Quiz Scores gets a required Score column that takes whole numbers from 0 to 100. The flow has the trigger Manually trigger a flow and one Send an HTTP request to SharePoint called Add Score.

Prerequisites​

  • Permission to change the list, such as Edit or Full Control on the site, for the account the flow's SharePoint connection uses.

Step 1: Add the Column​

Add Send an HTTP request to SharePoint, rename it Add Score, and fill it in:

FieldValue
Site AddressYour site
MethodPOST
Uri_api/web/lists/getbytitle('Quiz Scores')/fields/createfieldasxml
HeadersAccept: application/json;odata=nometadata
Content-Type: application/json;odata=verbose

The headers are under Advanced parameters. The body:

Add Score → Body
{
"parameters": {
"__metadata": { "type": "SP.XmlSchemaFieldCreationInformation" },
"SchemaXml": "<Field Type='Number' Name='Score' StaticName='Score' DisplayName='Score' Description='The score out of 100.' Required='TRUE' Decimals='0' Min='0' Max='100' />",
"Options": 25
}
}

The Add Score action with Method POST, the Uri _api/web/lists/getbytitle('Quiz Scores')/fields/createfieldasxml, the Accept and Content-Type headers, and the Body whose SchemaXml has Type Number, Name Score, Description The score out of 100., Required TRUE, Decimals 0, Min 0 and Max 100

The list title has a space, and it goes into getbytitle('…') as it is.

Step 2: Run the Flow​

Save the flow and test it manually (How to Test a Cloud Flow Manually in Power Automate). Add Score succeeded, and the list has its new column.

The Result​

In the list, I selected New, typed Ada as the title and 120 as the score, and selected Save. SharePoint refused it, at the top of the form and under the column:

The New item form with Error: The value of this field must be between 0 and 100. at the top, Title Ada, and Score 120 with The value of this field must be between 0 and 100. under it, above the description The score out of 100.

The message names the range from the XML: The value of this field must be between 0 and 100.

Common Mistakes​

MistakeWhat happensDo this instead
Min and Max the wrong way roundThe range doesn't mean what you meantMin is the lowest, Max the highest
Expecting Decimals='0' to stop decimals being typedThe reference describes Decimals as what's displayedTreat it as the display format
Double quotes inside the XMLThe JSON body breaksUse single quotes in the XML
Running the flow again unchangedIt tries to add the column a second timeCheck that the column is missing first

Troubleshooting​

SymptomLikely causeFix
The value of this field must be between …The value is outside Min and MaxEnter a value in the range
Status 404No list with that title on the siteCheck the title in getbytitle('…')
Status 403The connection's account can't change the listGive it Edit or Full Control

FAQ​

Can I add a range to a column that already exists?​

This request creates a new column. For one you already have, set Minimum allowed value and Maximum allowed value in its settings (How to Set a Minimum and Maximum Value for a SharePoint Number Column).

Does this need a premium licence?​

No. Send an HTTP request to SharePoint is part of the standard SharePoint connector.

Conclusion​

Put Min and Max in a number column's Field element, with Decimals for how it shows, and create it with createfieldasxml. A value outside the range gets The value of this field must be between 0 and 100., with your own numbers in it.

Additional Resources​