Need some help on using a repeating group as filter for another one

I have watched a few tuts and looked here for similar problems but did not find the answer.

I have two repeating groups:
Sessions and documents, both with their own eponymous datatype. Both are items the user can create.
Docs can be connected to sessions. I did this by creating two identical fields “number” for both datatypes. When a doc gets created, the user can select a session to which it connects. This gets copied to the Number field of the Document datatype.

I would like to create a function that when the user clicks a session, it sees only connected docs.

I am using custom states for this, but am stuck. This is what I have:
On the repeating group Sessions, I have a button with a workflow: Set State, Custom state “session filter” with Value “Parent group’s session’s number”
On the repeating group Documents, I have made a constraint on the datasource (datasource = search for documents, constraint: Number = [element]'s session filter

This actually works: when I preview and click a session, I see only the connected documents.
However, when I load the page, I see no documents. I understand this is because of the constraint, but I don’t know how to bypass it.
The user should see all docs when loading the page. Only after having set a filter, he should see filtered results.
Also I am not sure how to create the reverse: so when the user clicks a selected Session again, the filter gets cancelled and all docs become visible again.

Any help would be appreciated!

Add the data source you described above for Documents on to a conditional of the repeating group that only happens when the custom state “session filter” is not empty. Otherwise set the original data source for all documents.

Also you need two workflows for when the Session button is clicked. One would be if “session filter” is current cell’s session’s number and one if it is not. If it is then set the state to empty and if it is not then set the state to the current cell number.

Please tell me Discourse gives an award for this. :medal_military:

I think you could check the box to ignore empty constraint and it might work.

Thanks, with the help of you and rico trevisan combined it worked out!

Thanks, with the help of you and williamtisdale combined it worked out!

1 Like