# If Field

[IfField](https://docs.telerik.com/devtools/document-processing/api/telerik.windows.documents.flow.model.fields.iffield) is a [Field](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/concepts/fields/fields) element that compares two values and inserts the text appropriate to the result of the comparison.

## Field Syntax

The following table shows the syntax of an If field:

| Syntax                                                               |
| :------------------------------------------------------------------- |
| { **IF** *Expression1* *Operator* *Expression2* TrueText FalseText } |

### Operators

The following table lists all the comparison operators.

| Operator | Description              |
| :------- | :----------------------- |
| =        | Equal to                 |
| <>       | Not equal to             |
| >        | Greater than             |
| <        | Less than                |
| >=       | Greater than or equal to |
| <=       | Less than or equal to    |

### Expression1, Expression2

Values to compare.

### TrueText, FalseText

Text that results when the comparison is true (TrueText) or false (FalseText). If FalseText is not specified and the comparison is false, the IF field has no result. Each string containing multiple words must be enclosed in quotation marks.

## Inserting

You can insert an If field through the `InsertField()` method of [RadFlowDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/editing/radflowdocumenteditor). The method accepts code as first argument and result as second argument.

**Example 1: Insert a Money bookmark and an IF field that shows a minimum amount message when the value is below 100**

```C#
editor.InsertText("Wallet: ");
editor.InsertInline(new Run(document));
Run wallet = editor.InsertText("99");
editor.InsertBookmark("Money", wallet, wallet);
editor.InsertBreak(BreakType.LineBreak);

editor.InsertField("IF Money >= 100 \"Buy\" \"The minimum required amount is 100\"", "«T-shirt»");
```

The result of the above snippet is illustrated in **Figure 1**.

**Figure 1: If field in a document**

![Telerik RadWordsProcessing IF field example showing Wallet value 99 and the resulting The minimum required amount is 100 message](https://www.telerik.com/document-processing-libraries/documentation/assets/3717152c63286289a15867e366c80031/radwordsprocessing_concepts_fields_if_field_01.png)

## See Also

* [Working with Fields](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/concepts/fields/fields)
* [Custom Code Field](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/concepts/fields/customcodefield)
* [RadFlowDocumentEditor](https://www.telerik.com/document-processing-libraries/documentation/libraries/radwordsprocessing/editing/radflowdocumenteditor)
