Hi,
If I need to get the vehicles Data where ID in {1,2,3}, I can do this :
index( ri!vehicles, wherecontains( {1, 2, 3}, ri!vehicles.id ) )
But is there any way to do the same thing with a negation (a kind of notWhereContains) ? I mean I need to get the vehicles data where ID not in {1, 2, 3}.
Of course, I can then use a foreach to get the correct data, or create an exclusion list items, to apply the whereContains on the latter,
but is there any other way to do it with a single simple instruction ?
Discussion posts and replies are publicly visible
whereContains() essentially does this:
a!forEach( items: ri!array, expression: if( contains( ri!values, fv!item ), fv!index, {} ) )
Therefore you could create your own "where not contains" rule by flipping the internal logic of this:
a!forEach( items: ri!array, expression: if( contains( ri!values, fv!item ), {}, fv!index ) )
Thank you Mike, very interesting.
Initially a was using Foreach to make the "where not contain", then, I've tested Difference too.
In any case an internal foreach is used, so it does reply to my question...and I have some choice now :-)
My overall suggestion is that if you find yourself using such functionality often, encapsulate it in an expression rule where you decide what the input(s) and output are, then come up with the expression code afterwards (in which you could try different things or potentially change it in the future to something more efficient as new functions become available). I have lots of "quasi black-box" expression helper rules like this set up in my systems, and it takes a lot of the guesswork out of things.
Yes Mike, my initial post was indeed to see all the possible ways to do it, to create my own ER.
Not only for me but, to facilitate other eventual new programmers...