Frequently asked questions - Writer

    From The Document Foundation Wiki
    < Faq‎ | Writer

    Details on conditional fields in mailings

    Here is some additional information not available in the online help file.

    A lot of the time, a mailing has to "adapt" to the context: blank fields, grammatical rules, threshold values, etc.

    If the adaptation is limited to a word or an expression or a paragraph, we can use one ore more conditional fields. If important parts of the document depend on a single condition, we use sections.

    Use of conditional fields

    Three different type of conditional fields are available:

    • Conditional text: yields one value if the condition is TRUE and another one if it is FALSE;
    • Hidden text: the text (string) will not appear if the condition is met;
    • Hidden paragraph: the whole paragraph will not appear if the condition is met.

    Syntax of the condition:

    • when the condition includes a number, it should be input without a sign, while text should be in double quotes. eg: TEST==1 and not TEST=="1". Double quotes mean text and not a number;
    • when the field name includes an hyphen or a space, it must be put in square brackets, or the hyphen will be treated as a minus sign and the condition will return FALSE. eg : [Database.Table.E-mail]. This does not apply to a field that contains an underline character. ex : Database.Table.E_mail;
    • if the condition includes several criteria, each one must be in parentheses, with Boolean operators between them. Use the parentheses to set the order of priority.

    Example: (Town == "Lyon") and ((Title == "Miss") or (Title == "Mr")). This condition can also be written as: ((Town == "Lyon") and (Titre == "Miss")) or ((Town == "Lyon") and (Title == "Mr"))

    • most of the time, the condition is related to a data source field. Instead of entering the field name, it is possible to drag and drop it from the data source view:
      • click the field header then drag and drop it in the Condition area
      • do this drag and drop before completing the condition because the drag and drop replaces the content of the preceding area.
      • the field will be inserted under the form [Source name.Table name.Field name] so for example [Bibliography.biblio.Identifier]

    FR.FAQ Writer 052c.png

    • By default, hidden paragraphs are displayed. Check that the menu Tools ▸ Options ▸ LibreOffice Writer ▸ Formatting Aids, the box Fields : Hidden paragraphs is not checked.


    FR.FAQ Writer 052a.PNG

    Use of sections

    When several paragraphs, or whole parts of the document, have to be modified depending on a condition, it is easier to use sections. Sections can be hidden conditionally and a single test is enough to hide or display the whole of the text in the section. It is not be necessary to include conditional fields in the text, since it is the section which is conditional.

    Inserting a section is done via the Insert ▸ Section menu. Check the box Hidden and give the condition:

    FR.FAQ Writer 052b.png

    The conditions available for sections are the same as those for hidden or conditional text, but the drag and drop operation from the data source view is not available for sections. This can be worked around by the following tip: open Insert ▸ Fields ▸ Other (Ctrl + F2), Functions tab to use the drag and drop, then copy and close the dialog to copy in the section dialog.