Print Page | Close Window

newbie: customizing report data definition

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=386
Printed Date: 05 May 2024 at 2:51pm


Topic: newbie: customizing report data definition
Posted By: azad
Subject: newbie: customizing report data definition
Date 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



Replies:
Posted By: BrianBischof
Date 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>


Posted By: azad
Date 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


Posted By: BrianBischof
Date 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>


Posted By: azad
Date Posted: 25 Mar 2007 at 9:34am
Thanks so much for the information.

Regards.

Azad


-------------
Azad Bolour
http://www.bolour.com



Print Page | Close Window