Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: newbie: customizing report data definition Post Reply Post New Topic
Author Message
azad
Newbie
Newbie
Avatar

Joined: 22 Mar 2007
Location: United States
Online Status: Offline
Posts: 3
Quote azad Replybullet Topic: newbie: customizing report data definition
    Posted: 22 Mar 2007 at 4:03pm
I am trying to see if it is possible with the programming interface to Crystal Report to customize the data definition of the report to hide certain fields
from certain users, based on their access rights to such fields. Specifically,
if the user does not have the right to access a field of a table, and that
field appears in an expression to be presented on the report, the requirement would be to show a blank field instead. On the other hand, if a field that is to be hidden from a user appears in the condition or the join part of a data definition for the report, the report is not to present any data.

Is this kind of a thing possible to do by modifying the data definition for a
report dynamically? Is it documented which parts of the report object model are settable and which part not?

Thanks in advance for your advice.
Azad Bolour
http://www.bolour.com
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 22 Mar 2007 at 4:07pm
To do this you need to use datasets with custom SQL statements. Modify the SQL statement to blank out non-accessible fields. Now you don't want to remove them for the SQL altogether b/c Crystal Reports is assuming that the resultset will have the same structure. But just set them to "" in the SQL.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
azad
Newbie
Newbie
Avatar

Joined: 22 Mar 2007
Location: United States
Online Status: Offline
Posts: 3
Quote azad Replybullet Posted: 22 Mar 2007 at 11:03pm
Thanks for the reply. It is great to know that Crystal Reports makes this possible. Do you know if there is sample code from your book or other resources that does something similar?

Thanks.

Azad
Azad Bolour
http://www.bolour.com
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 23 Mar 2007 at 12:02am
I have examples of how to use datasets in my book and how to hide fields using the ReportObject class. Crystal Reports has examples of using datasets on their website.

For the SQL you would need to use something like this to keep a field in the dataset, but not have any data in it. In this example I set Field2 to be blank.
SELECT Field1, Field2="", Field3 FROM table

You would have to use conditional logic to dynamically create the Sql statement so that the proper fields are blanked out.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
azad
Newbie
Newbie
Avatar

Joined: 22 Mar 2007
Location: United States
Online Status: Offline
Posts: 3
Quote azad Replybullet Posted: 25 Mar 2007 at 9:34am
Thanks so much for the information.

Regards.

Azad
Azad Bolour
http://www.bolour.com
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.078 seconds.