cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Null handing in workato

TilakBhatia
Deputy Chef III
Deputy Chef III

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. 

1 ACCEPTED SOLUTION

TilakBhatia
Deputy Chef III
Deputy Chef III

Hi @brian and @gary1 , 

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

View solution in original post

4 REPLIES 4

gary1
Executive Chef III
Executive Chef III

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.

Brian_S
Deputy Chef I
Deputy Chef I

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.

 

TilakBhatia
Deputy Chef III
Deputy Chef III

Hi @brian and @gary1 , 

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

gary1
Executive Chef III
Executive Chef III

Thank you for sharing! I remember seeing this years ago and had completely forgotten about it.