Null check for a!map in a process

Certified Senior Developer

Hi together,

I have a "map" value in a process.

I realized that an IsNull/emptycheck rule I used in a gateway down the line, was failing of evaluating that there was (in my understanding) an empty value

cast(
  'type!{http://www.appian.com/ae/types/2009}Boolean',
  length(a!flatten(ri!value)) = 0
)



Even the new rules a!isNullOrEmpty ..... are not recognizing this properly.

Does anybody experienced this as well? (not difficult to solve, but it was pretty unexpected)

Kind regards,

Richard

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to Mike Schmitt

    True. Our null checker expression turned into black magic ;-)

    if(
      a!isNullOrEmpty(ri!value),
      true,
      a!localVariables(
        local!typeNum: a!refreshVariable(
          value: runtimetypeof(ri!value),
          refreshAlways: true
        ),
        
        /* Strings */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Text',
          /* Ignore white space */
          len(trim(ri!value)) = 0,
          
        /* List of Variant */
        if(
          local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Variant?list',
          all(a!isNullOrEmpty(_), a!flatten(ri!value)),
          
        /* Lists */
        if(
          /* Try to take first item in list and cast it to a list of itself */
          /* then compare its datatype to the incoming data type */
          local!typeNum = runtimetypeof(cast(runtimetypeof({index(ri!value, 1, null)}), ri!value)),
          
          /* Flatten takes care of lists in lists in lists in ... */
          /* List has zero non-null items, length() already ignores null values*/
          length(a!flatten(ri!value)) = 0,
    
        /* Map */
        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))
          ),
          
        /* DataSubsets or Maps returned by queryRecordType */
        if(
          or(
            local!typeNum = 'type!{http://www.appian.com/ae/types/2009}DataSubset',
            and(
              local!typeNum = 'type!{http://www.appian.com/ae/types/2009}Map',
              contains(a!keys(ri!value), "data"),
            )
          ),
          a!isNullOrEmpty(ri!value.data),
    
          /* No idea what this could be so it is considered to not be null */
          false
        )))))
      )
    )

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    Appian, please don't make us have to write things like this ^.