Check If an Input String Is an Integer Using Power Automate

Do you know how to check if a given input is an integer in Power Automate? Imagine you are working in a flow where a user inputs or SharePoint list values, and you need to validate whether a string contains a whole number before proceeding to the next steps. If the value is not a valid integer, your flow may give an error or incorrect results.

In this Power Automate tutorial, I will show you how to check if an input string is an Integer Using Power Automate.

Check If an Input String Is an Integer Using Power Automate

Suppose you are creating an automated flow for a customer feedback system. Users submit feedback via a Microsoft Form, which includes a field requiring them to enter their Customer ID, which should be an integer (12345). However, some users might accidentally enter non-numeric values (12a34 or abc).

Check If an Input String Is an Integer Using Power Automate

Now, in the Power Automate flow, you need to validate whether the Customer ID is an integer. If it is, the flow needs to be added into a SharePoint list; if not, it sends an email notification to the user asking them to correct their input.

To do this, follow the below steps:

1. Go to Power Automate and create a new flow. Choose the trigger: When a new response is submitted (Microsoft Forms connector). Select your form (Customer Feedback System) from the dropdown.

power automate check if number

2. Add the Get response details action (Microsoft Forms connector). Select the Form ID from the dropdown (dynamic content from the trigger). Map the Response ID to the trigger’s Response Id dynamic content.

Check if String is INT in Power Automate

3. Add the Initialize variable action and provide the below parameters:

  • Name: IsInteger
  • Type: Boolean
  • Value: true
How do you check if a string is an integer in Power Automate

4. Add the Compose action and provide the expression as below:

 int(outputs('Get_response_details')?['CustomerID'])

where “CustomerID” is the field name from your form (replace it with the actual field name from your form’s dynamic content).

How do you check if a value is numeric in Power Automate

5. Add a Set variable action and provide the below required parameters:

  • Name: IsInteger
  • Value: false
Check if a variable is numeric Power Automate

6. Then click the Set variable action -> click one Settings tab -> Set this action to run only if the Compose action has failed. Like the screenshot below:

Convert String to Number using Power Automate

7. Add the Condition action and add the below:

@{variables('IsInteger')} is equal to true.
Microsoft Flow How to determine a string is numeric

8. Then click the Condition action -> click one Settings tab -> click the + Select actions -> add the compose action:

Power Automate Check If an Input String Is an Integer

9. In the Ture section, add a Create item action (SharePoint connector) and provide the below required parameters:

  • Site Address: Select your SharePoint site.
  • List Name: Select your list.
  • Customer ID: Use the Customer ID from the form’s dynamic content.
  • Customer Name: Use the Customer Name from the form’s dynamic content.
  • Email: Use the Customer Email from the form’s dynamic content.
  • Feedback Comments: Use the Detailed Feedback from the form’s dynamic content.
How to convert the strings to integer on Power Automate

10. In the False section, add a Send an email (V2) action (Outlook connector) and provide the below required parameters:

  • To: Use the email field from the form (dynamic content).
  • Subject: “Invalid Customer ID”
  • Body: “The Customer ID you entered (‘[Customer ID]’) is not a valid integer. Please submit a numeric value.”
Check If an Input String Is an Integer in Power Automate

Save the flow, then submit test responses via the form:

  • Test 1: Enter “12345” (should log to SharePoint).
Power Automate Check If an Input String Is an Integers
  • Test 2: Enter “12a34” (should send an email).
How to Check If an Input String Is an Integer Using Power Automate

Conclusion

In this tutorial, we learned how to validate if an input string is a whole number (integer) in Power Automate. Using a Microsoft Form as the trigger, we collected a Customer ID and checked whether it was a valid integer using a Compose action with the int() expression.

If the conversion failed, we used a Boolean variable and configured the flow to detect the failure. Based on the result, we either added the data to a SharePoint list or sent an email asking the user to correct the input.

Moreover, you may like some more Power Apps tutorials:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App