Skip to main content
richardm900458
May 11, 2022
Question

Null check for a!map in a process

  • May 11, 2022
  • 13 replies
  • 0 views

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

    13 replies

    May 11, 2022

    Hi Richard,

    You should check what the value of the map type is inside the process instance. If it's null then it's length will be 0 but if the map value has been initialize during the process and has a structure, then it's value will not be 0. Something like this: 

    What was the error message that you were getting in the process instance?

    richardm900458
    May 11, 2022

    yeah the error message is fine. Nothing complicated.
    I think the {} is my issue here.




    A cdt structure is differently represented in a process then.

    I just expected a different behavior as the value is shown as {} not as (id: null, name: null) 
    it is more about the visual representation where i am struggling, i think.
    The issue of null values in a structure vs empty list -> {} is an empty list to me.

    Perhaps its just me. [emoticon:6d505171faa4497c85c5ca27290c555d]

    Edit: a!map doesn't seems to be intialized as a "list of variant" is saved into it.
    Edit2: Which is not working in an expression editor but in a process, if a process variable is of type a!map but the rule result you like to store has the type "list of variant".
    ...yeeeah....fun.....

    May 11, 2022

    All the data structures in Appian, if have been initialized in an expression or interface then are not considered as Null or Empty.  Therefore its length will be always at least 1. This is a key point. 

    In your example, you are comparing different things.. A single CDT with a list of CDTs.

    You have flagged the rule input as an array. If you uncheck that flag then the result will be different. 

     

    stefanhelzle0001
    May 11, 2022

    I would implement a null check for a map like this:

    or(
      length(a!keys(ri!map)) = 0,
      all(a!isNullOrEmpty(_), index(ri!map, a!keys(ri!map), null))
    )

    richardm900458
    May 11, 2022

    fine - works :)