Set text in a repeater with values from another repeater (=> as in relational databases)

Hi there,

i have a repeater A that also includes a column called “customer_id” and another repeater B (not in the same dynamic panel) that also has this “customer_id” column plus a “name” column.

What i want to achieve is use the customer_id from a row in A to select the name from repeater B. Much like the model of primary key and foreign key. Something like:

[[Item.customer_id == TargetItem.customer_id]] to identify the row. But how is it possible to access that “name” column then?

Thanks in advance,
Fab

Hi!

This works, though the method is pretty goofball. (There is no lookup function for repeaters, unfortunately.)

Repeater A has a column called id, repeater B has columns id and name. The goal is to display the name in repeater A, say on a rectangle called “name.”

Create two global variables, v_id and v_name

On repeater B (the lookup table), apply this filter OnLoad (not OnItemLoad)

 OnLoad
   Add filter [[Item.id == v_id]] to This

Repeater B’s OnItemLoad:

OnItemLoad
   set variable v_name to [[Item.name]]

Repeater A’s OnItemLoad:

OnItemLoad
   set variable v_id to [[Item.id]]
   set ItemsPerPage of repeater B to Unlimitied  -- this simply forces re-evaluation of repeater B's filter, which will use the new value of v_id set above, causing repeater B to set the appropriate value of v_name
   set text on rectangle "name" to v_name

You could also have variables v_address, v_phone, etc, though I have no idea what performance will be like.

lookup_by_id.rp (49.6 KB)

Very clever Joseph!
Thanks a lot.
Phil

Hey Joseph,

this is the solution!
To be honest id have never reached that goal by myself - thanks a lot.
And as Phil already said, a very clever solution :wink:

Greetz,
Fab

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.