Thanks for your answer. I had tried this before and it didn't work. I was really puzzled since I had seen that answer in many places in the forum and on the wiki. It turns out it was a copy/paste issue with the single quotes... My zen was tested again.
Ah, right, sorry. Discourse annoyingly automatically replaces the ASCII single quote with unicode fancy quotes, which wreaks havoc on copying and pasting some expressions.
I found a setting in discourse that claims to disable this behavior so that we won't have similar issues. Added some tests below
Hello there,
I have almost same issue here,
Menu and submenu whth no parent child relation, but I don't have case id value in the submenu instead, I have other case property which is Beneficiary_ID, which should be selected from the parent menu, accordingly, we should filter the submenu case list
you just need to consider which fields need to be filtered by which fields.
depending on which case list you are on, you can reference the "current case" properties by just using the property name in caselist filters.
the caselist filters run row by row, and assume that you are referring to the row currently being evaluated in your case list.
in Clayton's example
if(instance('locations')/locations/location[@id =
he is in the caselist filter for layer 2 if I understand correctly - it is generally a bit confusing when you're in that part of the system.
property_for_case_1_id is stored in the second layer's case.
instance('commcaresession')/session/data/case_id refers to the case that was selected in the parent menu.
so that code is saying "while I am in the second menu's case list, I want to check that the property from the second menu's case currently being avaluated has the same value as the case id of the case that I have selected on menu 1."
Many thanks for your reply, Mazen,
I did exactly same, but getting the error "Logic references instance(commcaresession)/session/data/Beneficiary_ID which is not a valid question or value."
the filter I added was like: Beneficiary_ID = instance('commcaresession')/session/data/Beneficiary_ID
where the Beneficiary_ID is the case property both in the case of the parent and submenu
where you put this filter matters in how you can access the information you wish to filter by.
for case_id is not the same as beneficiary ID. case id is a standard field in context that can always be referred to. beneficiary ID is something YOU added.
Howsit Mazz,
Oh my gosh this is so not working! I've followed the instructions perfectly (as far as I'm aware) as per Clayton's first reply. All I'm getting is the dreaded "Logic references instance(commcaresession)/session/case_id which is not a valid question or value."
The filter formula I'm using is "name_of_group = instance('commcaresession')/session/case_id" where name-of-group is a space seperated value of the case property of the Youth, and it's meant to use the module/menu selection to populate the case list if the name_of_group is matches the case id of the menu selection. Exactly as Guillaume.
Is there something in the broader environement i'm missing? All add-ons are activated.
so you are wondering why a space separated list of values is never returning true when you are comparing it to only one of those values?
of course it won't work "A B C D E" will never equal "A"
but, selected(list of values, value you are looking for) will if you are correct with what you are saying "list of case id's, against a single case id"
Lol, you are right. BUT, the issue isn't even that it's returning a false, it's not calculating, the error message is "is not a valid question or value".
I've tried using your suggestion here:
selected(name_of_group, instance('commcaresession')/session/case_id) as well as
selected((instance('commcaresession')/session/case_id), name_of_group) - Just in case I'm an idiot
I even tried "contains' as a function, same error.
the last thing that maybe causing this that I can think of is that you are maybe copy/pasting the code from the forum? if so, single and double quotes don't copy correctly into the code editor