Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Filtering a form content according to connected user

Questions related to using nuBuilder Forte.
Post Reply
eric29
Posts: 2
Joined: Wed Jul 12, 2023 5:01 pm

Filtering a form content according to connected user

Unread post 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?
eric29
Posts: 2
Joined: Wed Jul 12, 2023 5:01 pm

Re: Filtering a form content according to connected user

Unread post by eric29 »

Oooops ... Got it better with quotes around #USER_ID# which is well replaced in the query
luis_manuel
Posts: 2
Joined: Tue Jan 11, 2022 7:18 pm
Has thanked: 16 times

Re: Filtering a form content according to connected user

Unread post 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
Post Reply