WHERE IF Clause using global variable (security module)

I have a situation that I need to restrict viewing of specific records based on a user group from the security module. I used adz1111 advice (Thread - Security Module Application Access Validation) and captured the user group. There is also a field in the table that will determine if the record should not be viewed by all (publish = 0) or if it can be seen by all (publish = 1). I have added the following to the SQL Select Statement of the Grid Application:

WHERE publish >= IF((’[ugroup]’ != ‘Administrator’),1,0)

While this does work is this the best way to handle this type of requirement?

I don’t know this kind of SQL statement. I would suggest that you do something like : where publish >= [glob_select];
Then in the oninit event I would set the [glob_select] like

if([ugroup]==‘Administrator’)
{[glob_select]=1;} else {[glob_select]=0;}

Thanks Albert,

I like it better – I put it in the menu onApplicationInit with the ugroup code that way I can keep all of the glob_vars together in one app. Much easier to troubleshoot and revise later.