I am creating a organisation structure. I am having two kind of mobile worker i.e. Champion and Community Facilitator. I want Champion should be able to see the forms belongs to their group and vis-a-vis. But upon giving the below display condition when login as Champion, I am getting the below error.
Display condition : instance('commcaresession')/session/user/data/Champion = "Yes" and instance('commcaresession')/session/user/data/Community_Facilitator = "No"
Error : Logic references instance(commcaresession)/session/user/data/Community_facilitator which is not a valid question or value.
Same is happening when I am login as Community facilitator.
Dispaly condition: instance('commcaresession')/session/user/data/Community_Facilitator = "Yes" and instance('commcaresession')/session/user/data/Champion = "No"
Eror : Logic references instance(commcaresession)/session/user/data/Champion which is not a valid question or value.
This is not working. I am getting below error even if I am login from Champion id or Community facilitator id.
Logic references instance(commcaresession)/session/user/data/Champion which is not a valid question or value.
I have build both the mobile users modules in the same app and trying to access the modules which are assigned as per their work.
OR Shall I create two seperate apps for both. But in that case can the Community facilitator access the data submitted by Champions who are assigned to them.?
For clarity, you'd need to wrap the "Champion" reference in a similar check.
If these roles are mutually exclusive, you could also consider having a mandatory "role" field that's set to either "champion" or "facilitator" and making hte check
My guess is that there's some mismatch in the data. The fields are case sensitive, is there an uppercase/lowercase mismatch maybe?
I'd recommend using the Web Apps Data Preview tool while Logged In As the user you are testing, navigating to the menu, and using the "Evaluate XPath" tool to check what the data instance looks like.
I have checked the below condition in the preview options. I have checked both the conditions a. instance('commcaresession')/session/user/data/champion and b. instance('commcaresession')/session.
Below is the output I am getting.
The instance "commcaresession" in expression "instance(commcaresession)/session" used by "/" does not exist in the form. Please correct your form or application.
Also , without putting any condition to evaluating , I am getting below error all the time. I believe it is not impacting anything though.
Bad node: org.javarosa.xpath.parser.ast.ASTNodeAbstractExpr@8957e3c
Could you please let me know what could be the issue.
Are you evaluating the expression while on the menu page which contains the display conditions?
You'll only be able to evaluate while you are on a screen where the instances have been injected. It should work if you are looking at the blank screen where both forms have been filtered out before pulling up the Data Preview pane.
My issue got resolved. Technical team suggested to user the condition count(#session/user/data/Role) > 0 and (#session/user/data/Role = 'champion') as I have field defined as ROLE and not TYPE.