Custom Script Fragments

You can create an RTF Template Fragment to return data from a model script.  You do this by creating a model script that returns an XML string in a specific format.  You then add a reference to this script in the Template Fragment's Document Options.  After doing this you can add fields within the Custom section of your Template Fragment, which refers to the data that is returned by your model script.

Creating a Script Fragment

Step

Action

See also

1

Using the Scripting window, create a script that returns a string in XML format.

Examples are available of:

A Script that returns data in the appropriate XML format
The XML format that the Script must return so that it can be used by a Template Fragment

Scripting

Example RTF Template Fragment Script

Example Output of an RTF Template Fragment Script

 

2

Open or create a Template Fragment in the RTF Template Editor.

Right click on the Template background and select File | Document Options.

The Document Options dialog displays.

RTF Templates

Creating an RTF Template Fragment

 

3

Select the Custom Query tab and, in the Template Fragment type panel, select the Custom Script option.

A blank field displays to the right of the options.

 

 

4

Click on the drop-down arrow and select your Script from the list.

 

 

5

In the main text field on the tab, type the entry point of your Script that returns the XML data.

For example, if you were using the example script mentioned in step 1, then the entry point would be:

 

MyRtfData(#OBJECTID#);

 

 

6

Click on the OK button to close the Document Options dialog.

 

 

7

In the Document Template Editor, in the Sections panel, select the Custom checkbox to generate the Custom section.

 

Setting Sections for Reporting

 

8

Within the Custom section, right-click and select the Insert Custom Field context menu option.

A prompt displays for the name of the field to create.

 

 

9

In response to the prompt, type the name of the data field that is being returned by your script.

Referring to the example from step 1, you would add DateGen.

Click on the OK button.

 

 

10

Repeat steps 8 and 9 for each data field that you want to include in your report.

Add any other formatting and content you need, to the Template Fragment.

 

 

11

Save the Template Fragment, and add it to a standard RTF Template.

Adding Fragments to an RTF Template

 

Notes

Scripts have a limit of 60 seconds per call before control is returned to the Document Generator.

Learn more

Learning Center topics

(Alt+F1) | Reporting | RTF Template Fragments |
Create a Script Fragment 1
Create a Script Fragment 2