Template Scripts
In the Script Editor, C# or VB scripts can be created to achieve additional changes, behaviors, or functionality to a template when generated. This is where you can add any behavior that Bizview normally does not handle! These scripts are then connected to the template in the Scripts worksheet properties tab and executed accordingly. Since the knowledge about how to write these scripts depend on your C# / VB skills, we will only explain the user interface and the features available to you.
Access the Script Editor by selecting System > Designer Tools > Template Scripts:
The Template Scripts page displays, as shown below:
In the Template Scripts grid, you can view all saved template scripts and expand the detail view to see all templates linked to the specific script, as demonstrated below:
Open a script in the Script Editor by selecting the Script ID hyperlink.
In the Script Editor, you can write a script and add methods to the script that can be used in templates. For example, in custom buttons or events. One script can contain one, or several, different public functions/events (public voids).
When a function in a script is going to be used in a template, you first need to link the script to the template workbook (see Scripts).
Thereafter, the different public methods within the template script can be used in the template, either when managing Custom Buttons - Function or Events.
The scripts in the Script Editor are written in C#. In Script Editor, you get instant feedback if the code is incorrect. Hovering over a red-marked string that is incorrect provides additional information about the error.
Right-clicking and selecting Command Palette (or pressing F1 on your keyboard) returns all available commands that can be used in the editor area. Or, use a keyboard shortcut like Ctrl+F to search for specific strings in the script.
To write a new script, select the Add button in the ribbon. A Create New Script dialog displays, like below:
Enter an ID and a Description and select Create. An empty script displays, as shown below, and you are free to start writing the script.
In the Script editor you have some useful code snippets in the right panel that can be used to help you write you script.
You can either:
- drag-and-drop a code snippet into the script area - the snippet will be dropped where the marker is
- copy a code snippet by clicking the copy button and then paste it in script area by pressing Ctrl+V
Custom Code Snippets:
- Add your own code snippet by pressing the + button to the right in the Code snippets heading
- Delete any custom code snippet by pressing the trash-can icon
This topic contains the following sections:
Ribbon
Below is a list of buttons available in the Script ribbon:
Button |
Description |
Note |
---|---|---|
New |
Opens a new empty script template. |
|
Open |
Open an existing script. |
|
Save |
Save script. |
|
Save as |
Save as with new name. |
|
Delete |
Delete current script. |
|
Build |
Build and verify the script (Compile). |
Verifies that the code is valid (see Additional Information). |
Language |
Choose language. |
C# or VB. |
Generate document |
Generate a document to test the script. |
Used together with impersonation. |
Link to template |
Attach current script to Template(s). |
(see Additional Information). |
User |
Test the script with $User. |
Impersonation enables you to the script behavior depending on the User chosen. |
Client |
Test the script with $Client. |
Impersonation enables you to the script behavior depending on the Client chosen. |
Choose snippet |
Choose among commonly used code snippets available to you. |
(see Additional Information). |
Vertical view |
Arrange the windows vertically. |
|
Horizontal view |
Arrange the windows horizontally. |
Additional Information
Build: Compile the current script to check for errors. An error log is presented in the bottom including the row number for the error.
Link to template: To be able to use a script in a template, you need to link the script to the template. If not, the script will not be available for use in the Script tab in template properties.
Code snippet: When selecting a Code snippet, the code is copied to the clip board. Place the cursor in the script and select paste to insert the Code snippet.
Usage
The script(s) that are defined in the solution, can be attached to template(s) for execution in connection to generating a template. In the Scripts properties tab of any template design, you can setup the properties for running a script.