Skip to main content
June 22, 2023
Question

reject function giving error when all the items in the list are null

  • June 22, 2023
  • 4 replies
  • 1 view

reject() function giving error when all the items in the list are null

Example:

reject(fn!isnull, {null(), null(), null()}) --> error

Is this expected or it is a bug?

4 replies

mikes0011
Brainy
June 22, 2023

reject() and the other looping functions are legacy, and don't handle corner cases very well.  Almost all of them can be safely replaced by a!forEach() (sometimes wrapped in a!flatten()).  FWIW, the only legacy function I know of which can't be replaced thus, is reduce().

a!flatten(a!forEach(local!myList, if(a!isNullOrEmpty(fv!item), {}, fv!item)))

The Expression Guru
harshitb6843
June 22, 2023

I strongly agree with Mike. Ever since I realized that {} does not get returned in output, I have stopped using reject(). Please bear in mind that if you replace {} with anything in the above expression, then it will not be removed.

June 22, 2023

What error do you get?

It works perfectly fine for me

mikes0011
Brainy
June 22, 2023

Yeah, I still get a valid output even if I use OP's exact same original syntax.

The Expression Guru