Skip to main content
annap548
New Participant
Jun 10, 2021 5:01 PM UTC
Question

logical function AND()

Can anyone explain why and(null)  is true

1 reply

csteward
Brainy
Jun 10, 2021 5:16 PM UTC

Per the documentation on fn!and(), this function will only return false if any of the values provided are false, and it also notes that empty arrays evaluate to true.

The standard practice here if you may have an input value of null which you would like to return as false, is to check for these first within an if() statement.  This code below will check an array containing nulls and return false if any nulls are present:

a!localVariables(
  local!data: {true,null},
  
  and(
    a!forEach(
      items: local!data,
      expression: if(
        rule!APN_isEmpty(fv!item),
        false,
        fv!item
      )
    )
  )
)