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

Contents
Prev Next

Custom Query Fragments

You can create Template Fragments to return data from SQL Queries, or from Model Scripts. The first step in defining such Fragments is to use the Custom Query settings to enter your SQL Search, a starting point for your Model Script, or the existing template fragments that correspond to the specific types of element being reported.

Access

Ribbon

Publish > Documentation > Document Templates : <select a fragment template> : (Document Options icon) > Custom Query

Custom Query Options

Option

Action

See also

Custom SQL

Click on this radio button to enter an SQL Query.  

You can then add fields within the 'Custom' section of your Template Fragment, to refer to the data returned by the SQL Query.

Custom SQL Fragments

Custom Script

Click on this radio button to display a field in which you specify a Model Script; click on the drop-down arrow and select the name of the Script that will be used by your Template Fragment.

You can then add fields within the 'Custom' section of your Template Fragment that refer to the data returned by the Script.

Custom Script Fragments

Template Selector

Click on this radio button to define a template that calls in other Template Fragments depending on the element type being reported on.

Define a Template Selector

Document Script

Click on this radio button to display a field in which you specify the Model Script to be used by your Template Fragment. Click on the drop-down arrow and select the script from the list. The script must return either an empty string or a string that contains raw RTF.

See the example script.

Example Document Script

!INC Local Scripts.EAConstants-JScript

function main()

{

     var reporting as EA.DocumentGenerator;

     reporting = CreateDocumentGenerator();

     if(reporting != null)

     {

          if(reporting.NewDocument(""))

          {

               if(!reporting.LoadDocument("<filename>"))

               {

                    Session.Output( "Error: " + reporting.GetLastError() );

               }

               return reporting.GetDocumentAsRTF();

          }

     }

}

Learn more

Notes

  • Custom Queries and the Custom template section can only be used in Template Fragments; they cannot be used in normal, full-document templates
  • Custom Queries can reference the ID of the element or Package currently being processed by the document template, using the #OBJECTID# or #PACKAGEID# macros
  • #Branch# gets the IDs of the child Packages of the current Package being processed, working recursively down to the lowest level of sub-Package; this is only valid when processing a Package - elements return a 0 value
  • #UserName# gets the name of the user logged into version control
  • #Author# takes the user name from the 'Author' field in the 'General' page of the 'Preferences' dialog, so the defined search can be performed on objects created by that user (this value can be manually re-set in the 'Preferences' dialog)
  • #Package# gets the package_ID of the currently-selected Package
  • If you have a column or node with the name EABOOKMARK, this will insert a document bookmark around the parent section in the 'Contents' panel