How to use context group in model V2

Use case : manage user right depending its groups.

For example, you want some admin user to see a specific chart, but basic user not to, on the same report. In a model, you can get the context groups with :

:constants_contextVar_groups_ids

that gives you a string of all the user’s groups ‘18,19,27,600000,2,8’ (Jooma user group ids)

You can use it to check if your user is inside specific group :

SELECT ‘19’ = ANY (string_to_array(:constants_contextVar_groups_ids,',')) 

You can replace ‘19’ with a query that will give you the required group id (cast it as a text)

Finally, use this model for the conditonnal rendering of a grid item.