isNullorEmpty

Hi,

For the above expression rule, if I try to add a!isNullorEmpty(local!ID), then I can getting false, but I am expecting true.

Am I doing anything wrong here.

  Discussion posts and replies are publicly visible

  • I find myself agreeing with Mike (and you) on that front but not changing my behaviour. I tried about 6 months back...but then I forget and keep using index() anyway. I've used it for so long that my brain handles it being a number or a field name just as easily. I've also never had a Production incident or a personal issue in developing caused by using index() so personally it's a "solution" to a problem I don't have.

    But I'm also fine if property() was just removed. Traditionally I guess in computer science the index refers to the integer value but as far as I know that's just convention. There's nothing about the concept of index that says it has to be an integer value. But conventions are useful so...yeah. /shrug

  • 0
    Certified Lead Developer
    in reply to ajhick
    I've also never had a Production incident or a personal issue

    The current production system I inherited has some (thankfully somewhat rare) instances where there are 5-or-6-layer-deep nested index() calls where it's an arbitrary mixture between indexes and properties.

  • 0
    Certified Lead Developer
    in reply to ajhick

    I think that using "orEmpty" as in isNullOrEmpty does a great deal to imply the poster's original intent that he does want to consider the case of an empty set, and therefore IS NOT treating it as merely a scalar.

    What we need to consider is the 3rd possiblity, and indeed a 4th possibility also.  There's the possibility of a null, an empty set, a set of results that are all null, and also a set of results that are all empty:

    null, {}, {null, null, null}, and {{}, {}, {}}

    All 4 need to be addressed appropriately as they come up.  It appears the poster's intent for the third possibility and likely the fourth as well is to treat them the same as the first and second possibilities are already treated.  Assuming this, we present possible solutions for doing this.  I leave it for the original author of this thread to share if any worked or if our assumptions about his or her intentions are mistaken.

  • 0
    Certified Lead Developer
    in reply to ajhick
    The issue is the query returns a list but is being treated like a scalar value.

    I also think part of the issue here is that the user is expecting a single value to be returned from the query (unless i'm inferring incorrectly from their partial code), but they're not taking the necessary steps to make the returned result type "singular" before dealing with it.

    For instance, I often add an "index( [....], 1)" wrapper around my queries where i expect the value to always be "one and only one", both to disambiguate the code for future readers, as well as to make sure i don't get any surprised later on in the interface when i forget to deal with it like an array of one instead of a single value.

  • 0
    Certified Lead Developer
    in reply to ajhick

    This is a very interesting and healthy discussion on this topic.