Skip to main content
harshitb6843
August 29, 2022
Question

Issue: a!isNullOrEmpty() not working with blank a!map()

  • August 29, 2022
  • 3 replies
  • 0 views

While trying to check an empty map, a!isNullOrEmpty and a!isNotNullOrEmpty are not working, rather giving opposite result. 

The result of 

a!isNullOrEmpty(a!map())

should be true but the function is returning false. Not sure if this is a bug but something that might need the engineering team's attention. [mention:6b9f80ff18f9420082d13ef2d5121d56:e9ed411860ed4f2ba0265705b8793d05]

3 replies

stefanhelzle0001
August 29, 2022

I made this edge case part of my universal null check.

    if(
      local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Map',
      /* Has no keys at all or all values are null */
      or(
        length(a!keys(ri!value)) = 0,
        all(a!isNullOrEmpty(_), index(ri!value, a!keys(ri!value), null))
      ),
      

peter.lewis
Employee
August 29, 2022

Hmm, it does seem odd - that being said, I'm pretty sure behind the scenes this function is just doing a length() check on the value. If I do length(a!map()) it returns 1, so that's probably why this is returning false.

If you'd like, you could probably submit a support case and have the team investigate it. My hunch though is that it is behaving as expected given the result using the length function.

aparajitas0002
August 30, 2022

I have seen this happen multiple times within process models if we get an empty CDT map as a result and try to use this function to verify if it is empty. So I usually check one of the CDT's not null parameter to determine if the value is actually empty. if you are using a map, better to check either a not null key or all the keys.