Converting Forms strings to integers for use in Flow Expressions. #FlowFriday
>>Even when your taking numbers as answers its still being passed as a string!⌗
When your using Forms responses in your Flows each time you take a response it is passed into Flow in a string. But what if you’ve passed numbers that you want to then use that in an expression later on in your Flow?
>>How to get around it?⌗
In Flow at the moment there is no way to specify the answers passed through from your responses to be integers or strings. So to get around this we can use a Data Operation action that will turn out string into an integer so we can use in inside of an expression!
What I’ve done here is create a simple Flow to take the responses from a user to a Form and it will convert this one answer into an integer which I can use later on in the Flow inside an expression to do some math.
This first Data Operations Action called “Compose” is taking our String input from the responses to our Form question called “Add Numbers together!!".
Next we add another Data Operation “Compose” action that uses an expression of the output from our above Compose and turns it into an Integer. (You can rename the second compose action to a better name so its easier to find when referencing for your final expression)
The expression we use to do this is below:
Is this even useful? Well in most cases you might be perfectly fine just passing the numerical answer you receive as a string if your then going to just pass that out again in an email/teams message. But if you want to manipulate those numbers and do calculations for example: depending how many people where at a table for dinner calculate how many staff members would need to available working then you would need for that to be in an integer so you could create the expression at the end. For each 5 guests in a booking make sure you have at least 1 staff members. So 10 guests we’d need 2 members of staff then have that in an email to a manager to say “Make sure we have <2> members of staff”.
This was just an example but much much more can be done with this.