Document generation: Activities and content blocks

You can use Activities to create documents, forms, notes, tasks and e-mails based on a data from your composed application. A document can be generated to: - Word (doc, docx) and PDF, - E-mail.

Initial setup

To create a document you need components that add activity template/content block functionality linked to the export engine:

  • M3367, M3403, M3860 > for activity(ies), activity template(s);
  • M3251, M3888, M3890 > for content block(s), content block template(s);
  • M3363 > for an export definition.

UML

The basic UML looks like this:

For the activities without content block(s):

Activity Activity ActivityTemplate ActivityTemplate Activity->ActivityTemplate ExportDefinition ExportDefinition ActivityTemplate->ExportDefinition ExportField ExportField ExportDataSet ExportDataSet ExportField->ExportDataSet ExportDataSet->ExportDefinition

For the activities WITH content block(s):
Notice, that content block template has its own export definition (export definition > export dataset > export dataset fields)

Activity Activity ActivityTemplate ActivityTemplate Activity->ActivityTemplate ExportDefinitionForActivityTemplate ExportDefinitionForActivityTemplate ActivityTemplate->ExportDefinitionForActivityTemplate ContentBlock ContentBlock ContentBlock->Activity ContentBlockTemplate ContentBlockTemplate ContentBlock->ContentBlockTemplate ExportDefinitionForContentBlockTemplate ExportDefinitionForContentBlockTemplate ContentBlockTemplate->ExportDefinitionForContentBlockTemplate ExportFields ExportFields ExportDataSet ExportDataSet ExportFields->ExportDataSet ExportDataSet->ExportDefinitionForActivityTemplate ExportDataSet->ExportDefinitionForContentBlockTemplate

So any document falls under activities, and every activity is related to an activity template. Within the activity template there are two ways to create a document:

  • Classic: one complete template (.doc, .docx template),
  • Content blocks: template composed of reusable building blocks.

Notice, that activity templates and content block templates use the Export engine to replace variables (%link fields%) with a real data from you application, so you need to understand how export works.

Classic

You can use a document template attached to an activity template. The .doc template always contains the variable %activity_content%.

This variable (%activity_content%) is replaced by Activity template > Activity content OR by the content from content block(s) if you will attach any.

Document content could be hardcoded or, more frequantly, defined via the export definition. If you will assign an export definition to an activity template, you can use variables (%variable%) in you activity content.

Styles of a document could be set:

  • as inline style (source code),
  • as a corporate identity.

Content block

You can create a document with reusable parts - content blocks. Besides, content blocks have a preview, so you can view a document before generating it (the actual values are visible in preview on activity level; on other levels you can see variables):

Content blocks are built based on a content block template. Let’s have a closer look at it:

  • the most important is the linked export definition, it defines variables that will be resolved between %% in the “Content”. Note that texts between %% should contain lowercase letters and underscores and can be named exactly the same as they are in the export definition (check for typos!). Otherwise they would not be resolved.

  • changing the Read only checkbox will allow or restrict users from changing the content block in a document;
  • changing the Active checkbox will affect all places where this content block template is used. If you want to disable a particular content block in a particular document, please, toggle “active” checkbox the linked table or remove the content block from an activity template.

While creating an activity template with content blocks pay attention to sorting them on sequence numbers: they define the order in which content blocks appear in the document.

Export definition for an activity usuing content blocks

  • the output type can be either “human readable” or “excel”. This affects the way large numbers are displayed;
  • culture. In nl-NL it takes the default for dutch settings in Holland. In en-US mode it will take default settings for english in the United States. The culture setting affects numbers as well as date settings;
  • in the export definition you need to use a data set Activitycontentblocks > then you can define any fields.

The table “activitycontentblocks” needs to be present, for everything in a content block depends on that. This table must be a parent for other tables if you need any (for example, invoice lines). If we look at the second dataset, the top part contains our reference:

As we said above, you can assign the export definition to the content block template and use export definition fields as variables (between %%).

Editing a content block (template)

If you correct a spelling error, or make a minor, easily reversible, change, you can edit the original content block template. Remember, that this fix will affect all activity templates where there are content blocks based on this content block template!

But if you will edit a content block (not template) on an activity level > the changes will be applied only for documents generated from this activity.

As soon as changes are done (in content block templates or export definitions) > you can re-define content blocks on an activity level > and generate a document.

1 Like

Think article looks good. However it is not clear to me what is advised regarding creating Export definitions.
-Do you have one export definition where all content blocks can read from (lets say for a group of related content blocks)?
-Do you use the same export definition for the activity or do you create a seperate one?

Also it states capital letters are not allowed between %%. This is not what I found. It also works with capital letters.

Thanks

@michielb,
The .doc template (one is attached to an activity template) contains the variable %activity_content%, and it is replaced by the content from all content blocks (activity > activity template > content blocks grid). So if you have several content blocks, the content will appear according to the sequence of content blocks.

@michielb,
On the activity template level you have Export definition link > this export definition should incluse dataset with the data type = activities and field activity_content (field = content).
Every content block has its own Export definition link > it is an export definition with the data type = activitycontentblocks (Activity contentblocks).