User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:gendoc:gramatica [2017/07/27 01:23]
joebordes created
en:gendoc:gramatica [2021/07/12 20:38] (current)
joebordes
Line 1: Line 1:
-===== Documentation Generation::​Fields and Templates ​Grammer ​=====+===== Documentation Generation::​Fields and Templates ​Grammar ​=====
  
-We have a special helper extension ​which 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 out OpenOffice template documents.+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.
  
-==== Template ​Grammer ​====+==== Template ​Grammar ​====
  
   * **{entity.field}**   * **{entity.field}**
     * will be substituted by the named field of the named entity, these fields can be consulted in the OOMerge Fields extension if the field cannot be found it will be left unmodified, for example, {nonexistent_entity.fieldname},​ {entity.nonexistent_field},​ {sihubiera} or {sinexiste}     * will be substituted by the named field of the named entity, these fields can be consulted in the OOMerge Fields extension if the field cannot be found it will be left unmodified, for example, {nonexistent_entity.fieldname},​ {entity.nonexistent_field},​ {sihubiera} or {sinexiste}
     * examples: {account.accountname},​ {contact.bill_address},​ {product.productcode}     * examples: {account.accountname},​ {contact.bill_address},​ {product.productcode}
-  * **{siexiste ​entity}...{/​siexiste}** +  * **{ifexists ​entity}...{/​ifexists}** 
-    * all text contained inside the {siexiste} and {/siexiste} will be added to the final document if there exists at least one entity related to the main entity of the merge if none exist or entity is not defined the whole block will be eliminated inside the block fields of the first entity found may be used +    * all text contained inside the {ifexists} and {/ifexists} will be added to the final document if there exists at least one entity related to the main entity of the merge if none exist or entity is not defined the whole block will be eliminated inside the block fields of the first entity found may be used 
-    * examples: {siexiste ​asset}, ​ {siexiste ​contact}, {siexiste ​campaign}, {siexiste ​product}, {siexiste ​invoice} +    * examples: {ifexists ​asset}, ​ {ifexists ​contact}, {ifexists ​campaign}, {ifexists ​product}, {ifexists ​invoice} 
-  * **{siexiste ​entity.field=value}...{/​siexiste}** +  * **{ifexists ​entity.field=value}...{/​ifexists}** 
-    * all text contained inside the {siexiste} and {/siexiste} will be added to the final document if there exists at least one entity related to the main entity of the merge whose indicated field has the indicated value. For fields with multiple values (multiple select picklist), the string |##| must be used to separate the values and ALL values in the field must be the same as the value for the entity to qualify as equal. +    * all text contained inside the {ifexists} and {/ifexists} will be added to the final document if there exists at least one entity related to the main entity of the merge whose indicated field has the indicated value. For fields with multiple values (multiple select picklist), the string |##| must be used to separate the values and ALL values in the field must be the same as the value for the entity to qualify as equal. 
-    * if the entity or field do not exist the whole block will be ignored.+    * if the entity or field does not exist the whole block will be ignored.
     * inside the block fields of the first entity found may be used     * inside the block fields of the first entity found may be used
-    * examples: {siexiste ​asset.type=Fichero}, ​ {siexiste ​contact.type=Responsable Seguridad}, {siexiste ​campaign=GAdwords Noviembre08} +    ​* other operators are supported: %%> ​ <  >=  <=  =  !=%% 
-  * **{siexiste ​entity.field ​en (value1,​value2,​value3)}...{/​siexiste}** +    ​* examples: {ifexists ​asset.type=Fichero}, ​ {ifexists ​contact.type=Responsable Seguridad}, {ifexists ​campaign=GAdwords Noviembre08} 
-    * all text contained inside the {siexiste} and {/siexiste} will be added to the final document if there exists at least one entity related to the main entity of the merge whose indicated field has at least one of the indicated values. Fields with multiple values (multiple select picklist) are directly supported, no special syntax is needed. +  * **{ifexists ​entity.field ​in (value1,​value2,​value3)}...{/​ifexists}** 
-    * if the entity or field do not exist the whole block will be ignored.+    * all text contained inside the {ifexists} and {/ifexists} will be added to the final document if there exists at least one entity related to the main entity of the merge whose indicated field has at least one of the indicated values. Fields with multiple values (multiple select picklist) are directly supported, no special syntax is needed. 
 +    * if the entity or field does not exist the whole block will be ignored.
     * inside the block fields of the first entity found may be used     * inside the block fields of the first entity found may be used
-    * examples: {siexiste ​asset.type ​en (Fichero,​Contacto,​Aplicación)}, ​ {siexiste contacto.tipo en (Responsable Seguridad,​Responsable Ficheros)} +    * examples: {ifexists ​asset.type ​in (Fichero,​Contacto,​Aplicación)}, ​ {ifexists Contact.tipo en (Responsable Seguridad,​Responsable Ficheros)} 
-  * **{sinoexiste ​entity}...{/​sinoexiste}** +  * **{ifnotexists ​entity}...{/​ifnotexists}** 
-    * negative case of **{siexiste...}** +    * negative case of **{ifexists...}** 
-  * **{sinoexiste ​entity.field=value}...{/​sinoexiste}** +  * **{ifnotexists ​entity.field=value}...{/​ifnotexists}** 
-    * negative case of **{siexiste...}** +    * negative case of **{ifexists...}** 
-  * **{sinoexiste ​entity.field ​en (value1,​value2,​value2)}...{/​sinoexiste}** +  * **{ifnotexists ​entity.field ​in (value1,​value2,​value2)}...{/​ifnotexists}** 
-    * negative case of **{siexiste...}** +    * negative case of **{ifnotexists...}** 
-  * **{paracada ​entity}...{/​paracada}**+  * **{foreach ​entity}...{/​foreach}**
     * for each related entity of the main merge entity we will merge the whole text contained between the two commands and add the result to the final document     * for each related entity of the main merge entity we will merge the whole text contained between the two commands and add the result to the final document
     * if no related entity is found the whole block will be ignored     * if no related entity is found the whole block will be ignored
-  * **{paracada ​entity.field=value}...{/​paracada}**+  * **{foreach ​entity.field=value}...{/​foreach}**
     * for each related entity of the main merge entity whose indicated field has the indicated value we will merge the whole text contained between the two commands and add the result to the final document. For fields with multiple values (multiple select picklist), the string |##| must be used to separate the values and ALL values in the field must be the same as the value for the entity to qualify as equal.     * for each related entity of the main merge entity whose indicated field has the indicated value we will merge the whole text contained between the two commands and add the result to the final document. For fields with multiple values (multiple select picklist), the string |##| must be used to separate the values and ALL values in the field must be the same as the value for the entity to qualify as equal.
     * if no related entity is found the whole block will be ignored     * if no related entity is found the whole block will be ignored
-  ​* **{paracada ​entity.field ​en (value1,​value2,​value3)}...{/​paracada}**+    * other operators are supported: %%> ​ <  >=  <=  =  !=%% 
 +  ​* **{foreach ​entity.field ​in (value1,​value2,​value3)}...{/​foreach}**
     * for each related entity of the main merge entity whose indicated field has at least one of the indicated value we will merge the whole text contained between the two commands and add the result to the final document. Fields with multiple values (multiple select picklist) are directly supported, no special syntax is needed.     * for each related entity of the main merge entity whose indicated field has at least one of the indicated value we will merge the whole text contained between the two commands and add the result to the final document. Fields with multiple values (multiple select picklist) are directly supported, no special syntax is needed.
     * if no related entity is found the whole block will be ignored     * if no related entity is found the whole block will be ignored
-  * **{paracada ​entity.field!=value}...{/​paracada}** +  * **{foreach ​entity.field!=value}...{/​foreach}** 
-    * negative case of **{paracada...}** +    * negative case of **{foreach...}** 
-  * **{paracada ​entity.field !en (value1,​value2,​value3)}...{/​paracada}** +  * **{foreach ​entity.field !in (value1,​value2,​value3)}...{/​foreach}** 
-    * negative case of **{paracada...}** +    * negative case of **{foreach...}** 
-  * **repeticion**: inside the {paracada} blocks you can reference a special variable called {repetición} whose value will be that of the current loop iteration. This can be userful ​to enumerate the elements or to print conditional text based on the iteration. See [[:​en:​gendoc:​gendocejemplos|Examples]]. +  * **{foreach entity [field1 op value1 && field2 op value2 || field3 op value3]}...{/​foreach}** 
-  * **{incluir ​Document_Num}** +    * advanced conditions on fields with fields and operations %%(=,>,<,>​=,<​=,​!=)%% and limited logical connectors || (or) and && (and) 
-    *With this instruction we can include any document saved in the vtiger CRM document module inside the main document. For example, if we have a document with reference number DOC699, we can put at the beginning of a new paragraph {incluir ​DOC699} in the position where we wish to insert the document. During the merging process all the contents in DOC699 will be inserted in the position where the {incluir} directive is and the directive will be eliminated.+  * **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 [[:​en:​gendoc:​gendocejemplos|Examples]]. 
 +  * **{include ​Document_Num}** 
 +    *With this instructionwe can include any document saved in the coreBOS ​document module inside the main document. For example, if we have a document with reference number DOC699, we can put at the beginning of a new paragraph {include ​DOC699} in the position where we wish to insert the document. During the merging processall the contents in DOC699 will be inserted in the position where the {include} directive is and the directive will be eliminated.
     *You can use any other directive within the included document, following the same rules as any other document     *You can use any other directive within the included document, following the same rules as any other document
-    *Nesting of {incluir} directives is not supported (truth is that we haven'​t tried it)+    *Nesting of {include} directives is not supported (truth is that we haven'​t tried it)
     *At the beginning of the page that includes the document, check the Format>>​ Paragraph>>​ Text Flow>>​ Breaks, that the page number is set to 0 to keep the page counter from starting to count again.     *At the beginning of the page that includes the document, check the Format>>​ Paragraph>>​ Text Flow>>​ Breaks, that the page number is set to 0 to keep the page counter from starting to count again.
-  * **{incluir ​entity}** +  * **{include ​entity}** 
-    *With this command we can include, in the template, any document in the vtiger CRM document module that is associated ​to an entity directly related to the main entity of the merge. For example, if we have an entity //Backups// related to the main entity on which you compile the document, we can put at the beginning of a new paragraph {incluir ​Backups} (in this case it would seem logical to be inside a {paracada} 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.+    *With this commandwe can include, in the template, any document in the coroeBOS ​document module that is associated ​with an entity directly related to the main entity of the merge. For example, if we have an entity //Backups// related to the main entity on which you compile the document, we can put at the beginning of a new paragraph {include ​Backups} (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.
     *You can use any other directive within the included document, following the same rules as any other document     *You can use any other directive within the included document, following the same rules as any other document
-    *Nesting of {incluir} directives is not supported (truth is that we haven'​t tried it)+    *Nesting of {include} directives is not supported (truth is that we haven'​t tried it)
     *At the beginning of the page that includes the document, check the Format>>​ Paragraph>>​ Text Flow>>​ Breaks, that the page number is set to 0 to keep the page counter from starting to count again.     *At the beginning of the page that includes the document, check the Format>>​ Paragraph>>​ Text Flow>>​ Breaks, that the page number is set to 0 to keep the page counter from starting to count again.
-  * **{insertarindice}**+  * **{insertindex}**
     * A table of contents will be created from the outline of the document.     * A table of contents will be created from the outline of the document.
     * It can be used more than once in the same document but the TOC will be the same.     * It can be used more than once in the same document but the TOC will be the same.
-  * **{imagen ​entity}**+  * **{image entity}**
     *This directive must be at the start of a paragraph.     *This directive must be at the start of a paragraph.
     *The paragraph with the directive will be completely eliminated     *The paragraph with the directive will be completely eliminated
-    *The next paragraph must contain an image which will be the one substituted by the actual entity image+    *The next paragraph must contain an image that will be the one substituted by the actual entity image
     *In the case of needing various images, each image to be substituted must be different     *In the case of needing various images, each image to be substituted must be different
     *All the configurations made on the image will be respected, only the image will be substituted     *All the configurations made on the image will be respected, only the image will be substituted
     *We treat the image directives in a special way. The idea is that there are so many possible configuration options for an image (width, height, alignment, ...) that it would be complicated to include them in the image directive to indicate how the image should be rendered. So we decided that you include any image, format it as you need using the options that OpenOffice gives you for this and then we will substitute only the image leaving all the formating as you defined it.     *We treat the image directives in a special way. The idea is that there are so many possible configuration options for an image (width, height, alignment, ...) that it would be complicated to include them in the image directive to indicate how the image should be rendered. So we decided that you include any image, format it as you need using the options that OpenOffice gives you for this and then we will substitute only the image leaving all the formating as you defined it.
 +    *In case there is more than one image field on the module you can specify which one you want using the dot notation: Contacts.myimage.
 +    *There is a special case in the Project module to retrieve the GanttChart: **Project.GanttChart**
   * **Rules**   * **Rules**
-    * Directives must be on the same paragraph. There can not be a new paragraph in the middle of a directive. For example,<​code>​Dear {Contact.+    * Directives must be in the same paragraph. There can not be a new paragraph in the middle of a directive. For example,<​code>​Dear {Contact.
 firstname},</​code>​ is incorrect. firstname},</​code>​ is incorrect.
-    * The directives {siexiste}, {sinoexiste}, {paracada} and their closings must appear at the very beginning of the line in their own paragraph. The whole line will be eliminated. For example,<​code>​this is the end of the previous paragraph. +    * 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,<​code>​this is the end of the previous paragraph. 
-{siexiste activo.tipo=fichero} +{ifexists Activo.tipo=fichero} 
-This "si existe" works correctly while this one {siexiste activo.tipo=fichero} is ignored completely+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. and will be passed into the final document exactly as it is.
 This is another paragraph that may contain labels like: {Account.accountname}. This is another paragraph that may contain labels like: {Account.accountname}.
-{/siexiste}</​code>​ +{/ifexists}</​code>​ 
-    * If directives {siexiste}, {sinoexiste}, {paracada} 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. +    * 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,<​code>​{siexiste activo.tipo=fichero} and more text here on the same paragraph</​code>​ is incorrect. +    * Additional text after the special directives cannot be used. For example,<​code>​{ifexists Activo.tipo=fichero} and more text here on the same paragraph</​code>​ is incorrect. 
-    * {paracada} directives can be nested. +    * {foreach} directives can be nested. 
-    * {siexiste} directives can be nested with the exception of those in which a value coming from a {paracada} directive is being evaluated. For example:<​code>​{paracada ​Soportes} +    * {ifexists} directives can be nested with the exception of those in which a value coming from a {foreach} directive is being evaluated. For example:<​code>​{foreach ​Soportes} 
-  {siexiste ​Soportes.soporte_movil=1}+  {ifexists ​Soportes.soporte_movil=1}
      ​XXXXXXX      ​XXXXXXX
-  {/siexiste+  {/ifexists
-{/paracada}</​code>​In this case, the {siexiste} will evaluate the same entity as the {paracada}, and will fail. In general we can put {siexiste} inside a {paracada} if we are testing against a diferent entity, for example, this IS CORRECT:<​code>​{paracada ​Soportes} +{/foreach}</​code>​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 diferent entity, for example, this IS CORRECT:<​code>​{foreach ​Soportes} 
-  {siexiste ​Accounts.bill_provincia=Alicante}+  {ifexists ​Accounts.bill_provincia=Alicante}
        ​XXXXXXXXX        ​XXXXXXXXX
-  {/siexiste+  {/ifexists
-{/paracada}</​code>​ In this example all related Soportes will be listed and if the account belongs to Alicante it will also incorporate the block XXXXXXXXXXX.+{/foreach}</​code>​ In this example all related Soportes will be listed and if the account belongs to Alicante it will also incorporate the block XXXXXXXXXXX.
  
  
 ==== Special Text Formatting in Labels ==== ==== Special Text Formatting in Labels ====
  
-This is to allow formatting of text that is coming from the application. This feature allows you to format the text within a label, inside vtiger CRM. 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.+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 vtiger CRM. 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   * **<​b>​text</​b>​**,​ OpenOffice SIGPAC_BOLD style will be applied
Line 99: Line 105:
 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. 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 ​of character styles in the online documentation of OpenOffice. Here we can see the styles definition screen:+There is abundant information ​about character styles in the online documentation of OpenOffice. Here we can see the styles definition screen:
 {{:​gendoc:​estilocaracter.png|}} {{:​gendoc:​estilocaracter.png|}}
  
Line 108: Line 114:
 {{:​gendoc:​formatocaracteres.odt|Another example of character formatting.}}\\ {{:​gendoc:​formatocaracteres.odt|Another example of character formatting.}}\\
  
-==== Special fields ​==== +==== Company Information ​==== 
-  * In general all merging starts from an account and gives access ​to all the fields ​of all the related entities. + 
-  * In certain situations other entities may be used as the starting point of a merge+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
-  * SIGPAC has a series of constant fields obtained from the system: + 
-    * {empresa.campo}: ​information ​obtained from the organization details in settings +Since the information ​available on 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. 
-    ​{empresa.gerente_campo}:​ information of the head manager ​of the company + 
-    * {empresa.responsable_campo}: ​information ​of the legal responsible ​of the company +==== FAQ ==== 
-    ​* ​{cuenta.responsable_campo}: information ​of the LOPD responsible ​of the company+ 
 +~~QNA~~ 
 + 
 +??? How can I output a formatted date like "​26 ​of May of 2018"?​ 
 + 
 +!!! Like this: 
 + 
 +<​code>​ 
 +{date:dof {date:F} of {date:Y} 
 +and this would be the correct day of the week: {date:l} 
 +</​code>​