Skip to main content
Known Participant
Jul 29, 2023 12:26 PM UTC
Solved

Problem filtering null values from record

Hi!
I'm trying to filter out record where field 'value' is null, but it only gives the record of the first item, here's the code

local!validValues:ri!properties[where(a!isNotNullOrEmpty(ri!properties['recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{041a7f43-dfd1-4b07-aaed-48e305712f4e}value']))],

Any inputs?

Thank you

mathieud0001
Genius
Jul 29, 2023 12:53 PM UTC

Here's an example with a map but the same logic applies.

a!localVariables(
  local!values: {
    a!map(id: 1, value: "1"),
    a!map(id: 2, value: "2"),
    a!map(id: 3, value: null)
  },
  reject(
    a!isNullOrEmpty,
    a!forEach(
      items: local!values,
      expression: if(
        a!isNotNullOrEmpty(fv!item.value),
        fv!item,
        null
      )
    )
  )
)

5 replies

Inspiring
Jul 29, 2023 12:44 PM UTC

Rather than indexing, can you try applying the query filters using "not null" operator? This should ideally retrieve records that do not have null values.

Known Participant
Jul 29, 2023 12:51 PM UTC

the problem is that this is added data not in the record that i want to save after editing it

mathieud0001
Genius
Jul 29, 2023 12:53 PM UTC

Here's an example with a map but the same logic applies.

a!localVariables(
  local!values: {
    a!map(id: 1, value: "1"),
    a!map(id: 2, value: "2"),
    a!map(id: 3, value: null)
  },
  reject(
    a!isNullOrEmpty,
    a!forEach(
      items: local!values,
      expression: if(
        a!isNotNullOrEmpty(fv!item.value),
        fv!item,
        null
      )
    )
  )
)

stefanhelzle0001
Brainy
Jul 30, 2023 11:57 AM UTC

Another option that avoids that clunky (IMHO) way of trying to use foreach to filter a list.

a!localVariables(
  local!values: {
    a!map(id: 1, value: "1"),
    a!map(id: 2, value: "2"),
    a!map(id: 3, value: null)
  },
  index(
    local!values,
    where(
      a!forEach(
        items: local!values.value,
        expression: a!isNotNullOrEmpty(fv!item)
      )
    )
  )
)

Known Participant
Jul 30, 2023 12:09 PM UTC

Thank you