> For the complete documentation index, see [llms.txt](https://university.gonexa.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.gonexa.fr/doc/en/getting-started/conditional-display/create-simple-condition.md).

# Create a simple display condition

The IF condition lets you display text A or B based on a Salesforce criterion. It is binary logic: if the condition is true, Word displays result A, otherwise it displays result B.

**Case #1**

## Identify the logic

The IF condition lets you display text A or B based on a Salesforce criterion. It is binary logic: if the condition is true, Word displays result A, otherwise it displays result B.

The syntax works as follows:

```
{ IF "{!Objet|Champ}" = "Valeur attendue" "résultat si vrai" "résultat si faux" MERGEFORMAT }
```

It consists of 4 elements:

The **decision tag** is the Salesforce criterion on which the decision is based. It is the evaluated Salesforce field that carries the value to test.

The **operator** defines how the tag is compared to the expected value. It can be equal to `=`, not equal to `<>`, greater than `>`, greater than or equal to `>=`, or less than or equal to `<=`.

The **expected value** is what the field is compared against. Except for a currency, it is not enclosed in "".

The **text if true** and **text if false** represent exactly what will be displayed in the document depending on the result. They can contain text, tags, images, tables, pictograms, pages, paragraphs, or be empty "" to display nothing.

`MERGEFORMAT` is optional and standardizes the format of the displayed text.

## Basic configuration

First, define the logic you want to apply and the decision tag to base it on.

* Depending on the logic you want and its complexity, refer to the right section among the following options:

| Logic                                         | Description                                                | Example                                                                                                               |
| --------------------------------------------- | ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **A simple condition (Value A or B)**         | Trigger a condition based on a single criterion            | *E.g. Display the word apple if the "Show the word apple" checkbox is checked*                                        |
| **An advanced condition (AND, OR, AND + OR)** | Trigger a condition based on several criteria              | *E.g. Display a specific clause if the customer is a Key Account and the opportunity amount is greater than €100,000* |
| **A nested condition**                        | Trigger a condition within the result of another condition | *E.g. Display logo A if the brand is A, or if the brand is B display logo B, otherwise display logo C*                |

* Find the document template on which you want to create the condition and open its configuration
* Make sure the main object and the child objects (optional) are properly configured
* Open the Assistant from the document template

## Create the condition with the Assistant

* Using the Assistant, find the Salesforce field that will be the basis of your condition
* Click the 3 small dots at the end of the line
* Click "IF Add a condition"
* Complete the logic by entering, in the "Text if the box is checked" or "text if true" field and in the "Text if the box is not checked" or "text if false" field, the element that will be displayed in each case. You can then enrich the result if true and the result if false directly in Word.
* Click "Copy" to copy the condition to your clipboard

![Creating an IF condition with the Assistant](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/oCxHFY74qHMyWYejilx3/23-01-creation-if-assistant.gif)

## Insert the condition in Word

{% tabs %}
{% tab title="macOS" %}

* Click the "Insert" tab on the Word ribbon
* Click "Field"
* In the pop-up, paste the condition into the editable area, replacing the = sign already present
* Finish by clicking "OK"

![Inserting the condition in Word (macOS)](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/HnVlMFk5n6ZTAHR0XTCg/24-05-mise-word-mac.gif)
{% endtab %}

{% tab title="Windows" %}

* Click the "Insert" tab on the Word ribbon
* Click "Quick Parts", then "Field..."
* In the pop-up, paste the condition into the "Formula:" field, replacing the = sign already present
* Finish by clicking "OK"

![Inserting the condition in Word (Windows)](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/mPdKtgUtQw246CeamUYx/25-02-mise-dans-word.gif)
{% endtab %}
{% endtabs %}

{% hint style="danger" %}
**Warning**

A condition must be inserted using the procedure described above. Copying and pasting the condition as-is into the document will not trigger it.

For a condition using the = operator, the result if false is displayed by default in the document. If your result if false is empty, your condition displays nothing when it is closed.

Move on to the next step to open the condition and go further.
{% endhint %}

## Edit a pre-made condition

You can "open your conditions" to understand their structure or to enrich the results if true / if false with custom content

* From your condition, or after selecting your entire template, right-click > "Toggle Field Codes"
* Find the condition in its raw form:

```
{ IF "{!Quote|Afficher_pomme__c}" = "true" "Pomme" "" MERGEFORMAT }
```

* The condition contains two areas in quotation marks at the end: the result if true and the result if false. These are the only parts you should edit. Everything else is the structure of the condition: do not touch it.
* Between these quotation marks, you can write plain text or several paragraphs, insert images, tables or other Gonexa tags, or leave it empty. The content can span several pages and its formatting can be customized in Word
* Once your condition has been enriched, close it by right-clicking and selecting "Update Field". You will see the result if false or if true appear.

![Editing a pre-made condition](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/CqTPHhpatYhMAhCl7u51/26-03-modifier-condition-prefaite.gif)

{% hint style="danger" %}
**Warning**

The IF condition is sensitive. The slightest change outside the result areas can invalidate it. Before editing, turn on formatting marks (¶) in Word to clearly see the boundaries of each area and avoid errors.
{% endhint %}

```
{ IF "{!Account|Checkbox_pomme}" = "true" "Résultat si vrai modifiable" "résultat si faux modifiable" }
```

## Test your condition

* Upload your template with the condition as usual, by uploading a new version
* Find a record that matches your criterion. In our example, make sure the "Show the word Apple" checkbox on the account is checked
* Generate a document to validate that the condition works correctly
* Always test every alternative of your condition to make sure it has been built correctly

## Best practices

{% hint style="warning" %}
**Tip**

To get the cleanest and most reliable results, keep these best practices in mind:

**Preview before finalizing or adding complexity**\
Always run a test merge to confirm that IF statements display correctly, or build complexity into an existing condition step by step.

**Watch out for extra spaces**\
Word is sensitive to spacing. Even small errors can break conditions. Make sure there are no typos.

**Keep conditions simple**\
Overly complex nested IFs can become difficult to maintain, evolve or hand over to another administrator.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university.gonexa.fr/doc/en/getting-started/conditional-display/create-simple-condition.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
