Filter view of grid by user and value

Hello,

Is it possible that based on the user that enters into the grid, the results of the grid get filtered? For example im my user 1 belongs to the City = “NYC” then he can only see the results in the grid of the records that have the City as NYC and so on

Yes it is possible.

  1. When the user logs in create a global variable depending on his City. eg: [user_city]
  2. In the grid SQL add the where city = [user_city]
2 Likes

Thank you, and how can I do it if I specifically want one user to be able to see all the records?

This is possible, during grid execution time to add a field/condition to the search WHERE clause.

Ex. 1: It adds the content between the quotes (") in the grids select.
if (empty({sc_where_current}))
{
sc_select_where(add) = “where campoX > [global]”;
}
else
{
sc_select_where(add) = “AND campoX > [global_variable]”;
}

different approach:

make a blank app
make a table where the user id and the city is in
in the blank app create a select from table (see right panel) in OnExecute
store the result as a global [City]
sc_redir(grid_app, param1 = [City]; _blank)
in the grid use sql Where city = [param1]

this way the user can filter the grid without seeing any of the other city’s
The above works fine except when you use bootstrap buttons in your grid an let the user filter something (it gives an error)