Skip to main content
July 29, 2023
Solved

Problem filtering null values from record

  • July 29, 2023
  • 5 replies
  • 0 views

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

Best answer by mathieud0001

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

July 29, 2023

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.

July 29, 2023

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

mathieud0001
July 29, 2023

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
July 30, 2023

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)
      )
    )
  )
)

July 30, 2023

Thank you