Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Custom Script Fragments

You can create a Template Fragment to return data from a Model Script.  You do this by creating a Script that returns an XML string in a specific format.  You add a reference to this Script in the Template Fragment Document Options, then add fields within the Custom section of your Template Fragment that refer to the data returned by the Script.

Creating a Script Fragment



See also


Using the Scripting window, create a Model 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


Example Template Fragment Script

Example Output of a Template Fragment Script



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

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

The Document Options dialog displays.


Document Templates

Creating a Template Fragment


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.




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




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:



To convey Package information, you can replace #OBJECTID# with #PACKAGEID#.




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




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


Setting Sections for Reporting



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.




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.




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.




Save the Template Fragment, and add it to a normal Document Template.

Adding Fragments to a Document Template



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

Learn more

Learning Center topics

Alt+F1 | Enterprise Architect | Reporting | RTF Template Fragments |
Create a Script Fragment 1
Create a Script Fragment 2