reject function used with index function

Certified Senior Developer

How can we fetch only not null cases from this index function.

pls share the detailed query

  Discussion posts and replies are publicly visible

Parents
  • I prefer to avoid "reject()" and the other primitive looping functions where possible (which is almost everywhere), as a!forEach() does a better job, is more flexible, and is easier to understand.  Here we iterate over an array of "local!activeTasks" (pulling out arbitrary property "myProperty" first using the property() rule, which does the same thing as index() but we're using the appropriate one for the job it's doing here).  When any given iteration is blank, the loop returns an empty set.  (We wrap the whole thing in a!flatten() since otherwise if every iteration returns an empty set, it would give you an array of empty sets, which a!flatten() collapses to the desired single empty set).

    a!flatten(
      a!forEach(
        property(local!activeTasks, "myProperty", null()),
        if(
          a!isNotNullOrEmpty(fv!item),
          fv!item,
          {}
        )
      )
    )

Reply
  • I prefer to avoid "reject()" and the other primitive looping functions where possible (which is almost everywhere), as a!forEach() does a better job, is more flexible, and is easier to understand.  Here we iterate over an array of "local!activeTasks" (pulling out arbitrary property "myProperty" first using the property() rule, which does the same thing as index() but we're using the appropriate one for the job it's doing here).  When any given iteration is blank, the loop returns an empty set.  (We wrap the whole thing in a!flatten() since otherwise if every iteration returns an empty set, it would give you an array of empty sets, which a!flatten() collapses to the desired single empty set).

    a!flatten(
      a!forEach(
        property(local!activeTasks, "myProperty", null()),
        if(
          a!isNotNullOrEmpty(fv!item),
          fv!item,
          {}
        )
      )
    )

Children