Page 1 of 1

Filtering a form content according to connected user

Posted: Tue Jul 18, 2023 11:56 pm
by eric29
Hello,
I would like to select the rows for a form according to the user who is connected, for example with a corresponding email adress in zzzzsys_user and an email column in my data table. It should behave like a kind of permission at row level.
I read about #USER_ID# and also zzzzsys_session but I don't know how to get it working in the form SQL query.
Any idea?

Re: Filtering a form content according to connected user

Posted: Wed Jul 19, 2023 12:43 am
by eric29
Oooops ... Got it better with quotes around #USER_ID# which is well replaced in the query

Re: Filtering a form content according to connected user

Posted: Thu Jul 20, 2023 7:00 am
by luis_manuel
Hi Eric29
use code like this on the SQL of Browser Form

SELECT

task.idtask, task.detail, zzzzsys_user.zzzzsys_user_id, zzzzsys_user.sus_code, zzzzsys_user.sus_email

FROM
task left join zzzzsys_user on zzzzsys_user.zzzzsys_user_id = task.iduser

where ( (task.iduser = '#USER_ID#')
or
('#ACCESS_LEVEL_CODE#' IN('ORG_ADM','')))


at first par of SQL (task.iduser = '#USER_ID#') is useful to filter records before open in a Browser Form
and second part are useful to show all the records when im logged in like globeadmin in this case #ACCESS_LEVEL_CODE# = ''
you can add another profiles in Access level codes if you whan those view all records like 'ORG_ADM' in my example.

only you must make iduser of each table equal to that '#USER_ID#' that correspond to zzzzsys_user.zzzzsys_user_id

you dont need to use zzzzsys_session.

I hope this help you