Mark checkbox if certain options are selected from a list

Working in this document: https://coda.io/d/Mejor-prueba_d_mS8zXFCvi/_sulPv

Hello! I have clients which generate expenses and also pay me.

When a payment is added I want to SELECT FROM A LIST which expenses it’s cancelling and mark a CHECKBOX in the expense table.

I managed to get the multi-list working, but don’t know which formula to use to mark checkbox. I like the checkbox because I can check it even if no payment has been registered.

Thanks!

Since you still want to keep the checkbox manually checkable, a button might be the best option here.


Formula: thisRow.Movimientos.FormulaMap(CurrentValue.ModifyRows(Saldado,True()))

4 Likes

Wow Dalmo. THANK YOU!! :fist_right::fist_left:

bonus question: how could I make the Movimientos column list only unchecked values related to that row’s Cliente?

Dear @Mardoqueo_Sueldo,

You should create a view and filter the unchecked values and group by client.

Success :handshake:

I think this is what you mean… to filter the select list.

1 Like

Thanks for your help! Really appreciate

Any chance you could explain what your formula is doing here? I managed to get it to work in one situation, but not in another. Not sure how to debug…

For the button Saldar :
I’m not sure if I’m gonna say this properly, but FormulaMap() (See here :wink: ) kind of run a formula for each elements in “a list”

In this case, the list is ThisRow.Movimientos and the formula is :
for each CurrentValue (of ThisRow.Movimientos (which are the Cliente from [Movimientos]) mark the checkbox Saldado as True()

For the Filter(), It compares the 2 lists Cliente and Clientes and get only the Cliente where Saldado is False()

But, having played around a lot with buttons and checkboxes, for some reasons unknown to me, I also had troubles with that and found the solution in this post :

Hope this help a little :wink:

1 Like

FYI @Dalmo_Mendonca and @Pch:

No need for FormulaMap here. If you have a list of rows (in this case in Movimientos column), you can just feed that list to ModifyRows like this:

thisRow.Movimientos.ModifyRows(Saldado, true)

You generally only need FormulaMap if you need to calculate something based on CurrentValue. But in this case you just use a constant value true for each element of the list.

4 Likes

I’m just beginning to understand better how and when to use FormulaMap() in the appropriate way :wink: .

Thank you for this clarification :wink: !

It is technically appropriate, just unnecessary here because ModifyRows already consumes a list of rows — no need to run an action for each row individually.

But generally you use FormulaMap when:

  • you need to transform a list of values into another list of values (e.g. take a list of “Firstname Lastname” strings and only extract the first name)
  • you need to run different actions/or with different parameters for each row (e.g. for each Domain row only add it to another table if it’s not there already — although that sounds like the check would be better done in a separate step in a Domains table button)
  • in an indexed loop idiom: Sequence(...).FormulaMap()
  • in some very complex formulas where performing the transformation in a separate column of the source table is not possible or makes less sense (e.g., when inside the FormulaMap one needs to use values from thisRow).
4 Likes

I’m bookmarking this :grin: !
Thank you for all those complementary info :grin: !

1 Like

I can’t seem to make that one work :thinking:
The buttons only work if there’s only a single row selected:

Edit: Got it. Some functions like Filter() return a table, so you can use it to convert a list of rows into an anonymous table before applying ModifyRows:

Still don’t know how your code would work for the original post, though.

1 Like

I’ll get home and take a look. Although I think the column type could be a culprit there. It should be a lookup column with “Enable multi selection” enabled. Then in theory it should work (I don’t see why it wouldn’t)

UPD: Looked at your example. Hmmmmm :thinking: Interesting to know that .Filter() intrinsically returns something different than a list of rows. Thanks for figuring out the .Filter(true) trick!

1 Like

Awesome solution to a common problem!

I used your formula to check the “De Baja” box off.

It works by referencing the name (“Nombre Completo”), but not by referencing the email.

This works:
thisRow.[nombre-completo].Filter(true).ModifyRows(Integrantes.[De Baja],true)

This doesn’t work
thisRow.[tu-correo].Filter(true).ModifyRows(Integrantes.[De Baja],true)

Is it because Nombre Completo is the display column of Integrantes?

Any way to make it work by referencing the email without changing the display column?

Thanks for your valuable help!

No, this is because nombre-completo is a lookup and a row reference, and email is just a string.

If nombre-completo row(s) are searched by given email, then what’s the problem? It’s logical: you pull in the rows that correspond to that email, then pass it to ModifyRows to edit.

Otherwise you can rewrite the above formula by:
Integrantes.Filter(Email = thisRow.[tu-correo]).ModifyRows(...)

1 Like

You have an impressive grasp on what’s boing on within the formulas. As predicted, your edit made it work by referring email perfectly!

Thank you for explaining it to me, it’s much clearer now!