I have been trying to get a button formula to work for a while now but to no avail.
I have a Sale Order table and I need to fill a DB Clients table with the data from the former.
The thing is some clients have more than one order and that has to be filtered out, so I don’t get duplicates in the DB Clients table.
I’m sure there are other ways to accomplish this but I don’t want to use any formula or button column, as it would slow down my big doc.
The formula I wrote was:
Hi, @Paul_Danyliuk . Thanks for your help. I tried your way and it didn’t work either.
When you have two orders from the same client, the formula will not filter one out. You get duplicates in DB Clients.
If I try to run the formula again, it correctly doesn’t do anything, as the client was already added to the DB Clients.
It seems like DB Clients. Client ID doesn’t get updated while the formula runs and you get duplicates.
You could combine the two approaches then, first limit the orders to process with .Filter(...) and then additionally catch duplicates in recently created items with an inner
But I am under an impression that something else is not working in your formula? Otherwise your initial solution would work. What error are you experiencing?
Hi, Paul. I got it to work now
I think it’s a bug. All I did was to envelop the condition with RunActions().
The formula was not testing the inside condition in each iteration of FormulaMap() and, I believe, RunActions() forces it to check.
The formula that works is bellow. The only difference from the first one is the RunActions()
I renamed this thread because, I believe I found a bug in FormulaMap().
As you can see in the dummy doc, it doesn’t test a condition in each iteration even when the condition is inside FormulaMap(). I believe it’s not an expected behavior. You have to use RunActions() to get it to work properly.
Oh gosh, indeed! RunActions to recalculate the doc between iterations!
How could I forget the thing I even documented myself?
I don’t think it’s a bug but a feature. It’s a good thing that we can control it ourselves (sorta) whether we want to perform actions quickly (without recalculations) or want the doc to recalculate.