Adding Objects to and from the Repository
Different object types have different methods required to add the object to or from the repository.
Adding Text Objects and Images
To add text and image objects from the repository, the repository explorer should be open in Crystal Reports. To open the repository explorer, you need to authenticate with Crystal Enterprise. After this occurs, you can see all the folders and objects available in the repository. To add a text or image field, simply drag the field onto the report. You will notice that the object is read-only. To modify the object, right-click the object and select Disconnect from Repository (see Figure 17.2). You will then be able to modify the object. If the changed object is saved back into the repository with the same name, the original version will be replaced and all Crystal Reports that use this object can be updated.
Figure 17.2. To modify the object, the user needs to disconnect the object first.
To modify the object, you need to disconnect the object first. If the changed object is saved back into the repository with the same name, all objects that use this object can be updated.
To reconnect a text object or image to the repository, simply drag and drop the object from the Design or Preview tab on Crystal Reports back to its original repository object name in the Repository Explorer. A dialog will appear to confirm that you want to update the original object or add a new one. The user can then set the properties of the object by adding the required information.
CAUTION
The capability to store objects from Crystal Analysis reports in the repository was not supported at publication time.
SQL Commands
With the introduction of SQL Command objects to Crystal Reports, developers have been able to write custom database SQL to access data. The repository enables the developers to share these objects with others who might not have that skill set or those developers who do not want to reinvent the wheel.
To select a SQL Command from the repository, select the Repository from the Data Explorer or the Data step of the Report Wizard. Once again, Crystal Enterprise will ask you to authenticate to ensure you are a valid user. Select the required SQL Command from the repository (see Figure 17.3). If the command has any parameters associated with it you will be required to populate the parameters. This enables the SQL statement to run and populate the report with data, to give the report designer some data to work with.
Figure 17.3. The command objects as displayed by the Data step of the Report Wizard.
TIP
If you hover your mouse pointer over the SQL Command, it will display the SQL statement, enabling you to review the statement before selection.
To add a new SQL Command object to the repository, use the Data Connection, and then connect to the database desired in the Available Data Sources list box and choose Add Command from the list of available options. Select Add Command by double-clicking on it. This opens the Add Command to Report dialog. Then follow these steps:
- Enter the SQL statement you want into the query box. If parameters are required, you can use this dialog to create them as well.
- Before leaving this dialog, right-click the newly created SQL objects.
NOTE
For more in-depth information on Structured Query Language, see the supplemental material at the end of this book.
Custom Functions
Custom functions are reusable procedures that enable you to share logic across reports (see Figure 17.4). To allow for this sharing, the function needs to be data-and report-independent and specific guidelines must be adhered to:
- No User Function Libraries (UFL) can be used because these are machine dependent.
- No report or data source fields.
- You cannot associate a particular state with the function, such as Evaluation Time or Print State.
- You cannot use recursion, that is, the function cannot call itself.
- You cannot use variables, either shared or global, because these are report-specific.
Figure 17.4. A custom function in the repository displayed in the Formula Workshop; the summary shows a brief description of the custom function, return types, and function arguments.
CAUTION
Custom functions are not editable from the Repository Explorer because they are housed inside of Formulas. To view custom functions available in the Repository, go to Report, Formula Workshop. In the group tree, the Crystal Repository branch can be seen and all custom functions can be viewed from there.
Adding a new custom function to the repository needs to be done from within the Crystal Reports designer. The user can select the drop-down list from the new icon in the Formula Workshop. The function is then created and the user can select the Add to Repository icon, which adds the function to the desired location in the repository.
Organizing the Repository
The Repository Explorer represents the repository database as a tree structure made up of folders and objects. It is up to the report designer how he wants to organize it. For example, the sample Crystal Repository that ships with Crystal Enterprise 10 is sorted by object types. The folders are named to indicate their contents (Images, Text Objects, and Commands). However, the content creator or report designer can use folders to his organizational advantage.
To add new folders to the repository, right-click on the desired folder where the intended subfolder is to be placed. If the folder is intended to be at the root, right-click on the repository name. Choose New Folder from the context menu.
To move objects or folders, drag and drop the object to the desired location. To rename a folder, simply choose the folder to be renamed, right-click on it, and choose Rename from the context menu.