Organisation Structure and display condition

Hi Sims,

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.

help nedded!!

Are the custom user fields marked as required?

If you don't want to need to be able to set the value (IE: accept a blank value), you could wrap

instance('commcaresession')/session/user/data/Community_Facilitator = "No"

with a check for whether the value exists, IE:

(count(instance('commcaresession')/session/user/data/Community_Facilitator) != 0 and instance('commcaresession')/session/user/data/Community_Facilitator = "No")

Hi Sims,

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.?

You definitely won't need to make two apps.

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

instance('commcaresession')/session/user/data/role = "champion"

which would clarify the way this logic works.

Hi Sims,

I am getting below error.
Logic references instance(commcaresession)/session/user/data/role which is not a valid question or value.

Could you please help me with this. I am not sure whats getting wrong from my side.

Regards
Pragati Bansod

Hi Sims,

I have used below display condition for Champion :

count(instance('commcaresession')/session/user/data/champion) > 0 and instance('commcaresession')/session/user/data/champion= 'yes'

And for Community Facilitator:

count(instance('commcaresession')/session/user/data/community_facilitator) > 0 and instance('commcaresession')/session/user/data/community_facilitator = 'yes'

But I am getting blank screen now for both the groups.

Could you please know what could be the possible reason for this?

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.

You can try evaluating both

instance('commcaresession')/session/user/data/champion

to see what the exact reference returns, or you can evaluate

instance('commcaresession')/session

to display the general session data instance doc.

Hi Sims,

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.

Regards
Pragati Bansod

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.

Hi Sims,

I ma getting same error as mentioned above

hi sims ,

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.

Earlier I was using type in my syntax