Referencing a Lookup Table inside a repeat group

Hello,

I have a repeat group where the user selects a school for each repeat from a lookup table. The value stored is the school ID. I also want to retrieve the school_name

from the lookup table for each school selected in the repeat group.

In order to do that, I am writing in the form builder:

instance('schools')/schools_list/schools[school_uid = #form/school_list/school_uid]/school_name

However, this stores the value of the first school selected, instead of different values for each repeat group. I am also trying to use the current() function, but I have not figured out how to use it. I have tried:

instance('schools')/schools_list/schools[school_uid = current()/../#form/school_list/school_uid]/school_name but this is not working.

Any help will be appreciated. Thanks in advance!

@Francisco
I think you need to try :
instance('schools')/schools_list/schools[school_uid = current()/../../school_uid]/school_name rather than using #form/school_list/school_uid . The ../.. would depend on the path of your school_uid relative to the current repeat group.

Thanks for the prompt reply @ayogi .

Using ../.. or .../ is not working. The school_uid is taken from a Look Up table, and I get an error message that I need to include something like data/.. but I can't figure out what the exact path should be.

The .../ will definitely not work. The error you are mentioning comes when you are not referencing the right path of the question id. How many of /.. to be used is depends on the location of question you are trying to refer .
Can you look into the Calculations with repeat groups questions section of this page Using Repeat Groups in the Form Builder - CommCare Public - CommCare Public .

Also it would be great if you could share the screenshot of the question-id you are trying to refer using this notation.

Thanks @ayogi. The problem was on the /../.

This worked:

instance('schools')/schools_list/schools[school_uid = current()/../school_uid]/school_name

Appreciate the support. Best regards.