How to create multiple 'when conditions' in a Form

I create a Grid / Form application and it work fine when the access rights = ‘Admin’.

Now, I want to make use of the Form only when access rights = ‘User’.

First of all, when user login, I stored the login userid and access rights to global variable (eg. global_userid & global_rights).

With ‘Admin’ rights, I load the menu (menu4admin) with grid_user and link application to form_user, the value pass over is the userid. So, ‘Admin’ can view all users.

But when for user with ‘User’ rights only, I have a separate menu (menu4user) and load only the form_user. My question is: how I gonna pass the global_userid to the form? Where should I place the condition for ‘where userid = [global_userid]’? In this case, user only can view/edit his own data, not other user(s).

Regards,
CK

Re: How to create multiple ‘when conditions’ in a Form

When you pass the value to the form, the form can access the parameter in the SQL property.
Where Condition: userid = [global_userid];

You can pickup passed variables using [] in the linked form.

example:
in my grid, I have sc_link() in onRecord:
sc_link(client_ssn, treemenu_client_functions.php, id_client={id_client};c_fn={client_first_name};c_ln={client_last_name}, , “_self”);

in treemenu_client_functions.php: onLoad:
$_SESSION[‘session_id_client’] = [id_client];
$_SESSION[‘session_full_name’] = [c_fn].’ '.[c_ln];

The other option is to set a session variable $_SESSION[‘session_user_id’] = user_id;
This can be used throughout the project and if it is not set: if !isset(…) { redirect to login app } This could be in your onInit on each app so you can ask the user to login if there is an error in the session such as timeout, etc.

There is good tutorial on vars:
https://www.scriptcase.net/forum_en_us/index.php?topic=1380.0

Regards,
Scott.