Book a Demo
Prev Next

Exclude Package Query and Script

On the 'Document Options' dialog (Template Editor) or 'Options' tab (Document Generator) you can enter a custom SQL Query or select a custom Script to tailor the report in a specific way. One possibility is to exclude the selected Package or a child Package from the report. You can base your Query or script on the examples provided here.

The two parameters you use in excluding a Package are:

  • #PACKAGEID# - the Package_ID of the current record in t_package being processed on the exclusion condition
  • #OBJECTID# - the Object_ID of the current Package element record in t_object being processed on the exclusion condition

Custom SQL Query

To exclude the Package from the report using a Custom SQL Query, you can create the Query based on the t_package columns. For example:

     SELECT  Package_ID AS ExcludePackage

     FROM   t_package

     WHERE Package_ID = #PACKAGEID#

     AND      Name = 'Test'

Alternatively, you can create the Query based on the Package object columns in the t_object table:

     SELECT  t_package.Package_ID AS ExcludePackage

     FROM   t_package,t_object

     WHERE t_package.Package_ID = #PACKAGEID#

     AND      t_object.Object_ID =#OBJECTID#

     AND      t_object.Stereotype = 'NoDoc'

Custom Script

If you have selected the 'Custom Script' option and want to exclude the Package from the report, you can create a script and enter a call to it, such as:

     ExcludePackage(#PACKAGEID#)

This is a sample of the XML returned by the script:

     <?xml version="1.0"?>

          <EADATA version="1.0" exporter="Enterprise Architect">

          <Dataset_0>

               <Data>

                    <Row>

                         <ExcludePackage>

                         89

                         </ExcludePackage>

                    </Row>

               </Data>

          </Dataset_0>

          </EADATA>

This is an example of JScript for excluding the Package:

     !INC Local Scripts.EAConstants-JScript

     /*

     * Script Name: RTF Exclude Packages Script Sample

     */

     function ExcludePackage(packageID)

     {

          var xmlDOM = new ActiveXObject("MSXML2.DOMDocument.4.0");

          xmlDOM.validateOnParse = false;

          xmlDOM.async = false;

          var node = xmlDOM.createProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");

          xmlDOM.appendChild(node);

          var xmlRoot = xmlDOM.createElement("EADATA");

          xmlDOM.appendChild(xmlRoot);

          var xmlDataSet = xmlDOM.createElement("Dataset_0");

          xmlRoot.appendChild(xmlDataSet);

          var xmlData = xmlDOM.createElement("Data");

          xmlDataSet.appendChild(xmlData);

          var xmlRow = xmlDOM.createElement("Row");

          xmlData.appendChild(xmlRow);

          var package as EA.Package;

          package = Repository.GetPackageByID(packageID)

          if(package.StereotypeEx == "NoDoc")

          {

               var xmlName = xmlDOM.createElement("ExcludePackage");

               xmlName.text = "" + package.PackageID;

               xmlRow.appendChild(xmlName);

          }

          return xmlDOM.xml;

     };

Learn more