Getting unexpected results from IS_EMPTY

Why is this formula returning “True” even though the field is not empty?
IF(IS_EMPTY(LOOKUP((PICK_ITEM(data.Witticisms, appVars.viewedWitticismCount)), “button”)), true, false)

I also tried it without IF:
IS_EMPTY(LOOKUP((PICK_ITEM(data.Witticisms, appVars.viewedWitticismCount)), “button”))

CONTEXT
I am populating text and a button from my database.
Sometimes, the message doesn’t require a button.
In that case, the “button” field will be empty, and I want to hide the button entirely.
I use this formula in a condition in the logic, and hide the component if it returns “true.”

Right now, if I use IS_EMPTY, it returns “true” whether or not the field is empty.

App 98690
Page Setup Activities List

In case it’s a clue, it’s also returning “false” in an IF_NULL function–whether or not the field is null.

I wasn’t able to resolve the issue directly, but I worked around it by putting a formula into the Visibility toggle rather than hiding the component via logic.

Are you sure your data is populated straight after page is mounted?

The next time I run into this, I’ll double check. Thanks, @Sasu_Makinen!

1 Like

I’ve run into this issue again, unfortunately.

CONTEXT

  • Users can click a button to see a collection of records.
  • If the collection is empty, I want the button to disappear so they can’t click into an empty page.

LOGIC

  • I added some steps to the data variable logic.
  • After the page loads and the collection is fetched, I check to see if the collection is empty.
  • If it is empty, I hide the button.
  • I use this formula: IS_EMPTY(LOOKUP(PICK_ITEM(data.PendingInvites, 0), “inviterName”))

RESULT

  • The button is hidden regardless of whether the record is empty.
  • I get the same result from IS_NULLY.
  • IS_NULL gives the opposite response.


App #98690
Page Activities

Could you render the object on screen and verify it’s empty? For example put up a Paragraph component and use formula ENCODE_JSON(LOOKUP(PICK_ITEM(data.PendingInvites, 0), “inviterName”))

Or look up from debugger.

@Sasu_Makinen, it is very good that you pose these questions to us users :slight_smile:

In the process of getting screenshots showing that the data was empty (it was in every instance), I noticed that the GET request to populate the data was actually failing in one specific spot. We had made a change to the data source that I updated everywhere but there. So it would populate in some places (because it was pulling the data from a different, functional step), but not there.

So mystery solved! I appreciate the AppGyver team being available to rubber ducky. I wouldn’t be able to use the platform successfully without it. Thank you.

1 Like