We have a special helper extension that can be found under the Tools menu called OOMerge Fields. This extension will list all available fields for each module and their internal name so we can easily copy and paste the field names into our OpenOffice template documents.
{entity.field}
{ifexists entity}…{/ifexists}
{ifexists entity.field=value}…{/ifexists}
{ifexists entity.field in (value1,value2,value3)}…{/ifexists}
{ifnotexists entity}…{/ifnotexists}
{ifnotexists entity.field=value}…{/ifnotexists}
{ifnotexists entity.field in (value1,value2,value2)}…{/ifnotexists}
{conditional entity.field==value}…{/conditional}
{foreach entity}…{/foreach}
{foreach entity.field=value}…{/foreach}
{foreach entity.field in (value1,value2,value3)}…{/foreach}
{foreach entity.field!=value}…{/foreach}
{foreach entity.field !in (value1,value2,value3)}…{/foreach}
{foreach entity [field1 op value1 && field2 op value2 || field3 op value3]}…{/foreach}
{foreach ... *sort directive*}…{/foreach}
{foreach Timecontrol [title=MyTitle && tcunits>5] *date_start DESC*}
{foreach Timecontrol *date_start DESC* [title=MyTitle && tcunits>5]}
{foreach Timecontrol *date_start DESC*}
{iteration}: inside the {foreach} blocks you can reference a special variable called {iteration} whose value will be that of the current loop iteration. This can be useful to enumerate the elements or to print conditional text based on the iteration. See Examples.
{include Document_Num}
{include entity}
{include Backups}
at the beginning of a new paragraph (in this case it would seem logical to be inside a {foreach} loop because an account probably has more than one backup) in the position where we want to insert the document. When compiling all the documents related to the Backups will be inserted in substitution of the {include} directive.{insertindex}
{image entity}
Rules
Directives must be in the same paragraph. There can not be a new paragraph in the middle of a directive. For example,
Dear {Contact.
firstname},
is incorrect.
The directives {ifexists}, {ifnotexists}, {foreach} and their closings must appear at the very beginning of the line in their own paragraph. The whole line will be eliminated. For example,
this is the end of the previous paragraph.
{ifexists Activo.tipo=fichero}
This "if exists" works correctly while this one {ifexists Activo.tipo=fichero} is ignored completely
and will be passed into the final document exactly as it is.
This is another paragraph that may contain labels like: {Account.accountname}.
{/ifexists}
If directives {ifexists}, {ifnotexists}, {foreach} are used at the start of a paragraph (which is mandatory) but the paragraph is inside a list, then the corresponding closings must also be added as a paragraph inside the list. This can be accomplished with the ALT-INTRO key combination. Additional text after the special directives cannot be used. For example,
{ifexists Activo.tipo=fichero} and more text here on the same paragraph
is incorrect.
{foreach} directives can be nested.
{ifexists} directives can be nested with the exception of those in which a value coming from a {foreach} directive is being evaluated. For example:
{foreach Soportes}
{ifexists Soportes.soporte_movil=1}
XXXXXXX
{/ifexists}
{/foreach}
In this case, the {ifexists} will evaluate the same entity as the {foreach} and will fail. In general, we can put {ifexists} inside a {foreach} if we are testing against a different entity, for example, this IS CORRECT:
{foreach Soportes}
{ifexists Accounts.bill_provincia=Alicante}
XXXXXXXXX
{/ifexists}
{/foreach}
In this example, all related Soportes will be listed and if the account belongs to Alicante it will also incorporate the block XXXXXXXXXXX.
{conditional} directives can be nested. We can use {conditional} inside {foreach} and define one or some conditions. For example:
Compiling against a Potential record with a foreach CobroPago.
The following payments are higher than 500$
{foreach CobroPago}
{conditional CobroPago.amount > 500}
{CobroPago.parent_id}
{/conditional}
{/foreach}
In this case, the Payment parent ID will be shown for each record of Payment in the related list of Potentials that has an amount higher than 500$.
Example 2:
{foreach CobroPago}
{conditional CobroPago.paid==1}
{conditional CobroPago.paymentmode in (Cash)}
Potential has carried out an operation with value {CobroPago.amount} and paymentdate {CobroPago.paymentdate}
{/conditional}
{/conditional}
{/foreach}
In this example, we have defined 2 conditions, so if we want to use more than one condition inside foreach we can do that by adding one after the other, so if the payments have been paid and the payment mode has been Cash the information inside the conditional block will be added to the end result, if not it will be excluded from the end result.
This is to allow the formatting of text that is coming from the application. This feature allows you to format the text within a label, inside the application. In other words, the format is introduced when creating the text in the appropriate field of the application, then the document generator will convert these formats directly into comprehensible elements in OpenOffice. Only 4 types of formatting items are allowed, with which it is possible to apply any OpenOffice format to the text.
<b>text</b>, OpenOffice SIGPAC_BOLD style will be applied
<i>text</i>, OpenOffice SIGPAC_ITALIC style will be applied
<style estilo=openoffice_style>text</style>, OpenOffice openoffice_style style will be applied
<br> <br/>, line break (NOT paragraph break)
This formatting will be applied to any text contained inside the directives.
Nesting of < b> and < i> is not supported, use < style> to create this effect.
The character styles SIGPAC_BOLD, SIGAC_ITALIC or any other defined by the user must be created in the template by the user, the document generator only applies the style, it does not create it, if it is not defined the text will appear normal.
There is abundant information about character styles in the online documentation of OpenOffice. Here we can see the styles definition screen:
This is the template used for testing the functionality where the styles definitions can be seen.
This is an example of how the text looks inside the field of vtiger CRM.
<b>EVIDENCIA</b>: El Responsable de seguridad declara que los sistemas de información se han sometido a la precpetiva auditoría bienal en <br/><style estilo=MiEstilo>materia de protección de datos</style>
<i>DEFICIENCIA</i>: No se aprecian.
This is the finished, merged document.
Another example of character formatting.
We can also access the company information configured in the Settings section of the application using the meta label Organization as you can see in the OOmerge Labels extension.
Since the information available in the company settings section is rather limited and you could need more, the install process created the global variable GenDoc_Company_Account where you can set the accountid of any Accounts record from which you wish to access your company's information. The idea is that you create an account record for your company and use all the fields there.
Like this:
{date:d} of {date:F} of {date:Y}
and this would be the correct day of the week: {date:l}
Next| Chapter 3: Documentation Generation::Non Supported Elements