How to reject values in a CDT array on the basis of a condition?

Hi All,

I want to reject values in a CDT array on the basis of a condition.

For ex - I have a CDT array of type, suppose, type!someType(a,b), where a and b are fields in CDT. Now, My array looks like below:

{

type!someType(a: 1, b: null)

type!someType(a: null, b: 1)

type!someType(a: null, b: null)

},

I want to filter this array and get only those CDT values where a <> null.

What can be the possible way to do it?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • May I indicate one issue with the foreach-filter habit. In case no item matches the condition, the created list is a list of empty lists {{}, {}, {}, ...}. This can break any subsequent code and can be a pain to debug. This is why I still recommend the "old" looping functions filter() and reject() and asked Appian to come up with new filter functions similar to a!foreach().

  • 0
    Certified Lead Developer
    in reply to Stefan Helzle

    FYI, I've noticed this before as well, and more recently I've figured out that wrapping the entire a!forEach() statement in a!flatten() also handles this scenario (with much less bad taste in the back of my mouth than using the old looping functions).

    (In fact, I was considering including it in my answer above, but I thought for the moment it might be better to not over-complicate things.. now i'm not so sure)