Help with nested loops and the new WithName() formula

Hi @Breno_Nunes ,
basically you are asking the button - in plain english:

Hey, would you please create a new row in the Item table for every entry that is selected in the Orders table

The key here is for every and the only way to instruct the processor to do that is through FormulaMap().

The WithName() function only allows to, well, give a name to an expression.

I have the feeling you might have interpreted the RunActions() as an implicit FormulaMap()
For every row of my dataset do…”.
As a matter of fact, RunActions() allows just to group sequentially different actions; for this reason, here is redundant (but working)

So let’s dissect the formula:

Orders.Filter(Unarchive) // let's take the selected orders
    .FormulaMap( // for each Order record we have
    CurrentValue.WithName(ChosenOrder, // give it the name ChosenOrder and...
    Item.AddRow( // add a new row on Item table
        Item.[Order Number],ChosenOrder.[Order Number] // with the values taken from the current ChosenOrder
)))

In this case you should need to have a record reference (such as First() or Nth() or Last()) in order to execute an action on that record.

Please, tell me otherwise.
Cheers!

9 Likes

Dear @Federico_Stefanato,

Excellent explanation, you make coding in this way understandable, with an easy entrance level :trophy::trophy::trophy:

Much appreciated :pray:

3 Likes

Thank you very much @Federico_Stefanato for you explanation.
Actually RunAction() is not redundant for my use case. As this was only a mock doc, I didn’t mind adding a “2° action”
Still I did work with Orders.Filter(Unarchive).first() or using .FormulaMap(). as you said.
It helped me a lot. Thank you