Document Generation

When documents are simply stored and retrieved (see Document Management) Aware IM does not do anything with the contents of the documents – it stores documents in its original form and never modifies them in any way. However, document storage and retrieval is not the only way Aware IM can work with documents – it can also generate documents from document templates.

Document templates are defined in the Configuration Tool. When defining a document template the configurator has to indicate the type of template and design the template layout. The following types of document templates are supported:

  • Report
  • MS Word
  • MS Word (XML format)
  • MS Excel
  • Text
  • HTML

Custom types can be plugged in as well (see Extending Aware IM). Layout of the template is specified using the software corresponding to the type of the template (for example, MS Word for Word templates, any text editor for text templates etc). Report templates are created using the Report/Presentation Designer (see reports and Working with Report/Presentation Designer).

Configuration of document templates is described in the Adding/Editing Document Templates section.

Tag Elements

The essential feature of document templates is that they can contain tag elements. A tag element is a special text within a document template that starts with the << symbol and ends with the >> symbol. Whatever text is contained between these symbols is called tag contents. Tag contents must be of a particular format that corresponds to the format of arithmetic expressions in the rule language – see the “Usage of rules inside tags” section in the “Aware IM Rule Language Reference” document. Most tag elements refer to a value of a particular attribute of a business object. For example,

<<Account.Balance>> 

Below is an example of the usage of this tag element within some document template (which can be of any type). This document template could be part of an account statement or part of a letter to a customer:

The current value of your account’s balance is <<Account.Balance>> dollars. 

Document generation creates documents out of document templates by replacing tag elements with the appropriate values. Tag elements referring to attributes are replaced with the values of these attributes. In the example above if the actual value of the Balance attribute is 1000 the text in the resulting document will look like this:

The current value of your account’s balance is 1000 dollars. 

If tag elements contain expressions with attributes Aware IM calculates the expressions and replaces tag elements with the resulting values. The values of attributes are taken from the Context (see Context of Rule Evaluation and Other Usages of Context). In the example above it is assumed that the instance of the Account business object is present in the Context.

Tag elements used in document templates may also contain conditional expressions that let you specify conditions under which attribute values or static text will be printed out. The format of a conditional expression is the standard format used in rules. The only difference is that these expressions must contain the special SHOW action. An example of a conditional expression:

<<IF Account.Balance > 1000 THEN 
 SHOW Account.Holder.Name>> 

If balance of the account is greater than 1000 then include the name of the holder in the document.

You can also conditionally include the entire sections of a document template into the final document. To define a condition of section inclusion, add the condition followed by the action SHOW SECTION_START. This also marks the start of the section. To mark the end of the section include, the following tag: <<SECTION_END>>. For example,

<<IF Account.Balance > 1000 THEN SHOW SECTION_START>> The text of the section follows ... <<SECTION_END>> 

The rest of the text follows

note

conditional inclusion of document sections is only available for MS Word and HTML document templates. Some document templates types allow inclusion of tables using LIST_TABLE and LIST_TABLE_START/ LIST TABLE END functions. MS Word document templates also support inclusion of sub-documents using SUB_DOCUMENT function (see Report Functions).

The mechanism of document generation that works by replacing tag elements with the corresponding values can be very effectively used to generate multiple documents from the same document template. For example, one could define a template of a letter to a customer. When this letter is sent to a particular customer, the tag elements in this letter referring to customer’s name, address etc will be replaced with the details of this particular customer.

When documents are generated

Aware IM generates documents from document templates in the following scenarios:

  1. When instances of business objects containing attributes of the Document type are created provided that the attributes are initialized with a document template.
    It is possible to initialize an attribute of the Document type with the name of a document template (see Setting Properties of Document Attribute). In this case when an instance of a business object containing such an attribute is created Aware IM uses the document template that the attribute is initialized from to generate the document. The instance of a business object being created is available in the Context and may be referred to by tag elements of the template (Note that all other attributes of the business object are guaranteed to be properly initialized before document generation occurs – see Rule Priorities). Once the document has been generated it is stored as the value of the Document attribute (see Document Management).
  2. When the name of a document template is specified in certain actions from within business rules.
    The DISPLAY DOCUMENT, EXPORT DOCUMENT and PRINT DOCUMENT actions of the Rule Language can specify the name of a document template to display, export or print. It is also possible to assign a value of an attribute of the Document type to the name of a document template, for example
    Account.Statement = 'StatementTemplate'  

    In each of these cases Aware IM generates the document out of the specified template before executing the action (for example, when Aware IM executes the DISPLAY DOCUMENT action it generates the document out of the template first and then displays the resulting document). The current Context of rule execution is used to resolve the tag contents.

  3. When a user invokes an operation of the “Create Document” type in the Operation Mode.
    An operation of the “Create Document” type can be configured to be part of the main menu or can be invoked from a form of a business object or a query. The Context for document generation is formed from the instances of the business objects that a user selects and/or the data source of the document template (see Other Usages of Context).
  4. When tag elements are used in the initialization text of attributes of the Plain Text type.
    Tag elements may be used in the initialization expressions of the Plain Text attributes. In this case there is no document template involved but nevertheless Aware IM replaces tag elements used in the initialization expressions with the appropriate values before assigning initial text to the attribute.
  • Last modified: 2022/09/13 18:15