CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Restrict rows based on user's region

Print topic Send  topic

Author Message
aegregory

Posts: 7
Posted: 05/02/2006, 7:30 AM

In my application, the security group called 'operations' needs to be able to see records for their entire region. In the [users] table I have a field called 'region'. Is it possible to use the CCDLookup function to pull the user's region and use it in a WHERE clause? Or is there a way to set the user's region to a custom session variable upon login?
View profile  Send private message
Frosty555

Posts: 7
Posted: 05/05/2006, 12:42 PM

I haven't delved too deep into using CCDLookup() to retrieve data from a database so I won't give you syntax for that, I'm sure you already know how to use it.

However, there is an event in the grid object called BeforeBuildSelect which is executed just before the grid executes the query specified by it's datasource. If you add custom code to the BeforeBuildSelect event of your grid, you can alter the datasource just before it is used:

Function mygrid_DataSource_BeforeBuildSelect  
     mygrid.DataSource.Where = [expression]  
End Function  

Replacing [expression] with your CCDLookup() call. You may want to do something like this, however, incase you are already using a WHERE clause in your datasource and you don't want to overwrite it:

Function mygrid_DataSource_BeforeBuildSelect  
     if mygrid.DataSource.Where = "" then  
          mygrid.DataSource.Where = [expression]  
     else  
          mygrid.DataSource.Where = mygrid.DataSource.Where + " AND " + [expression]  
     end if  
End Function  
View profile  Send private message
aegregory

Posts: 7
Posted: 05/05/2006, 12:50 PM

Thanks. I'll give that a try. Just a few minutes ago I found a posting on how to create a custom session variable by modifying Common.asp. So far it seems to be working for me. If I run into a problem I will give your solution a try.

I didn't save the link but I did copy the instructions:

"In the project explorer, right-click Common Files and choose Open.
Under the Common Files tab, click on Common.asp.
Find the CCLoginUser function (you can find this towards the end, it's the second to the last function listed).
In the SQL variable, add your extra field in the select statement.
About two lines below, you'll find and IF statement (If Result Then....),
you can add a session variable and assign the field your added on the sql
statement you added in the SQL variable:
e.g. Session("MyNewSessionVar") = RecordSet("MyAdditionalField")
Regenerate/publish the Common Files.

I use the added session field in my pages by putting
Session("MyNewSessionVar") in the default property of the object (label,
text field, etc.). Works like a charm for me :)"
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.