Option set filtering

Hello Community,

Is there a way to filter option sets for options based on the user group / user logged in ?

eg:
Options a,c can be viewed by only Username 1.
Options b,d can be viewed by only Username 2.

I know that this can be done with category options but I do not know how to achieve this in option sets.

Thanks.

Abumere Ejakhegbe.

2 Likes

Hello @Abumere_Ejakhegbe,

Thanks for your question.

I have not actually tried whether this works in practice, but maybe you can add the different options from an option set into two different option groups - so A and C in one option group and B and D in another. Then, you could create a program rule with the program rule action “Hide option group” which triggers for example based on the user’s user role - d2:hasUserRole. Then the user should only see the options that are not in the hidden option group.

Let me know if you get the chance to test out whether that works!

Best regards,
Karoline

4 Likes

I will give this a try and will give a feedback. Thanks @Karoline

1 Like

Hi Abu- have you determined whether this works? I would like to do this as well.

1 Like

We can test it out on play.dhis2.org @kstankevitz! Thank you for your question! I’ll give it a try on play too. :blush: Feel free to post if you get to it before I do. :+1:

I actually got this working- apologies for not posting an update sooner. It worked just as Karoline described, with the below action/expression in the program rules.

expression: d2:hasUserRole(‘xxxxxxxxxx’)
action: hide option groups

1 Like

Thanks Kayla! (:

#copmonthly :grin::+1: