01-11-2024 05:48 AM
Hi Members,
I'm facing a scenario where errors occur in fields of integer, number, and datetime types when they meet a specific condition, especially when no value is assigned.
For instance, an error is triggered when the condition "completed_hours greater than 0" is met with a null value for 'completed_hours', resulting in the message: "Error calculating input for field 'condition': (missing field value) greater than 0." However, this can be resolved by putting 'completed_hours' not null check before applying the comparison. However, this introduces additional code, and when dealing with multiple fields, it becomes time-consuming to write such code.
Is there a built-in feature in workato that automatically handles these checks and comparisons without the need for extra code assume that if null being passed it fails the condition expect result:
"completed_hours greater than 0" -- true if completed_hours is 9
"completed_hours greater than 0" -- false if completed_hours is 0
"completed_hours greater than 0" -- false if completed_hours is null
Regards,
Tilak Bhatia.
Solved! Go to Solution.
01-22-2024 05:21 AM
Found the solution of the above problem. You can refer the link https://www.workato.com/product-hub/how-to-handle-nulls-2/ for future references.
Regards,
Tilak Bhatia
01-11-2024 09:25 AM
I don't have a solution for you, but I think this is really about "null handling in programming."
If you're only testing the variable once, then it is what it is -- you need to handle the null. But in situations where I have to test the variable multiple times throughout a recipe or script, I will normalize it first in another variable so I don't need to repeat the presence check/null handling over and over.
Probably not super helpful, but that's all I got! Maybe someone else will have a better suggestion.
01-11-2024 12:02 PM
Without code? Probably not. I assume you're doing this in a field? You could do something like this:
(completed_hours.presence || 0) > 0 or just (completed_hours || 0) > 0 might work.
Nulls are false, so "|| 0" will assign the second value, the zero.
A more verbose way of doing it: (completed_hours.present? ? completed_hours : 0) > 0
Or a fun one: [null, 0].exclude?(completed_hours). 0 or null will be false, all others will be true.
01-22-2024 05:21 AM
Found the solution of the above problem. You can refer the link https://www.workato.com/product-hub/how-to-handle-nulls-2/ for future references.
Regards,
Tilak Bhatia
01-22-2024 09:09 AM
Thank you for sharing! I remember seeing this years ago and had completely forgotten about it.