Flow condition evaluating incorrectly – output shows 2 but compared as 2.0 and evaluates false
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi,
I’m facing an issue in Flow Designer where a condition is not evaluating correctly.
In my flow, a Script Action returns a numeric output variable called count.
The output shows count = 2, which is correct.
In the next step, I have a condition:
If (count is greater than 1 or count is 0 and rehire is yes)
And if output is 0 and rehire is yes it's getting evaluated as true.But when output is 2 it's evaluating as false.
Has anyone else faced this issue where numeric outputs from Script Actions are not correctly evaluated in Flow conditions?
Any suggestions or best practices to handle this?
Thanks
- Labels:
- 
						
							
		
			Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @SameeraD ,
This behavior happens because even if your Script Action returns a numeric value (e.g., count = 2), Flow Designer often treats all outputs as strings unless they’re explicitly typed or cast.
As a result, conditions like count > 1 are evaluated as string comparisons, which can lead to unexpected results.
To Fix It
- Set the correct data type for the output variable - In your Script Action’s Outputs section, make sure the count variable’s data type is set to Integer (or Number) — not String. 
 
- Cast the output value to a number in your script 
 Use parseInt() to ensure the value is truly numeric before assigning it to the output.
(function execute(inputs, outputs) {
    var numericCount = 2; // Ex
    // Ensure the output is an integer before returning it
    outputs.count = parseInt(numericCount);
})(inputs, outputs);
Or use a flow variable and convert the string to number.
Please mark this as helpful and correct, if this helps you.
Thanks,
Yaswanth
