Is it possible to put a casedb expression in a CommCare module filter? I only want the module to show up if there are cases of the module type.
Is it possible to put a casedb expression in a CommCare module filter
commcare
Related Topic
- Can a User Case be accessed through a module by another user
- CommCare – Date Filter for Case Export: Last Modified Date vs Opened Date
- When using CommCare Supply, will the WebApps functionality work with supply-point cases
- Module filter with multiple expressions
- List the parent_name of a child case in the child case module case list
- Please specify exactly which cases will sync down to a mobile device when using CommCare
- How to trigger CommCare to create user cases
- Can you create child cases from a repeat group in advanced modules in CommCare
Best Answer
Yes, this is possible. The module filter (for module with case-type "notification") ends up being:
count(instance('casedb')/casedb/case[@case_type = "notification"][@status = "open"]) > 0
The [@status = "open"] piece is key to get the right behavior in the time period between when the last case is closed and the next sync (when it gets removed from the phone).