1714
Views
10
Comments
Solved
Check if Binary Data is null
Question
Hi

How do I check if a Binary data attribute is null (or has content) ? I've tried "<attribute> = NullBinary()", however I get an error message saying 2 binaries cannot be compared.

Accoring to the help on the NullBinary() function, the check above should work

Any ideas?
mvp_badge
MVP
Rank: #2
Solution
Hi Bilal,

The "=" operator is not valid for Binary Data. There's a Compare function in the BinaryData extension that lets you compare two variables of type Binary Data. Compare(yourBinaryDataVariable, NullBinary()) works fine, for example. You could also use the BinaryDataSize function from the same extension. It returns 0 if theres no binary content.
Rank: #10592
Hi Kilian

Thanks.  Works like a charm

Bilal
mvp_badge
MVP
Rank: #2
Hi Bilal,

Good to hear! Glad I could be of help.
Staff
Rank: #28

Hi Chetan,


It is part of the System Components, so you should already have it in your environment. Try to find it in the Add Reference screen.


Also just for the record: on the next major version it will also be possible to compare with NullBinary() to check if a binary is empy.


Regards,

João Rosado

Rank: #65138

Hi,

I have tried "<>" operator, Compare and BinaryDataSize in mobile app development but it isn't working. Basically, the BinaryData API is not working in case of mobile. Please shed some light here what to use in mobile development in Outsystems for checking image attribute.


Regards,

Isha

Staff
Rank: #28

Hi Isha,


For mobile you can use the " = NullBinary()" to check if its empty. Not sure if the "<>" operator was implemented, but you can always do a "not (somevariable = NullBinary())" as alternative if you really want a negated expression.


Regards,

João Rosado

mvp_badge
MVP
Rank: #2

Hi Malalai,

You did not follow my instructions, at least I don't see the Compare Function, and you use "=", which I explicitly stated doesn't work.