I’m trying to create a workflow with two prompts and based on the inputs given, makes some simple math. The workflow has only two constraints:
The inputs entered, can only be numeric values. The workflow can’t proceed if the values entered aren’t numeric.
Also, negative numbers aren’t allowed.
So… I started the workflow and it works with the first condition. However, when I try to add the condition of the negatives number being allowed the workflow stops working. Here’s the what I’ve done:
Convert the negative value to positive value [ Example : if user enter -45 as input convert this input to positive by using Math.Abs(Variable) and you will get 45 as output]
Have one If condition while stating if Variable contains (“-”), Prompt msg that Invalid Input and terminate or continue as per your requirement [ If Condition = Variable.ToString.Contains(“-”)]
You can use regular expression to check whether input string is number or not.
In addition, based on your workflow, even if one value is not a numeric, you are asking user to enter both the values. But in a standard solution, you don’t need to proceed further until the first value is valid.
Hey @moreirasa1
Just keeping it simple, you will want to check if it’s Numeric before checking if it’s less than 0
The condition can be like this:
If(IsNumeric(sNumberOne) And IsNumeric(sNumberTwo), CInt(sNumberOne)<0 And CInt(sNumberTwo)<0, True)
So if you place that entire line into your condition, it will first check if both values are numeric, then check if they are <0. If they are not numeric it will go to the True side. Basically, I used an inline If statement, useful for making comparisons that need to be a certain type before making.
I liked your solution above the others because it was a very simple approach. Also thanks for your explanation and indeed, it seems to work with your tips. Nevertheless, I found a new solution that I will put here just in case for future knowledge sharing: