---
title: Conditional Clauses
description: CONTRACT Butler conditional logic is applied during the contract creation process. For this purpose, clause tags with simple or complex expressions can be used in custom contract creation flow. Tag is a label or keyword that describes the content of…
url: "https://pdfbutler.com/academy/contract-butler-academy/contract-butler/conditional-clauses/"
updated: "2025-07-01"
category: CONTRACT BUTLER
---

# Conditional Clauses

CONTRACT Butler conditional logic is applied during the contract creation process. For this purpose, clause tags with simple or complex expressions can be used in custom contract creation flow.

Tag is a label or keyword that describes the content of a clause and can be used for logical operations. The tag is not unique within the template and can be applied to multiple clauses.

#### Example:

Create a Template or make use of any existing template to add tags for the clauses. Let's create a template on opportunity object and add multiple clauses. Let's hide the each clause based on Opportunity's Lead Source. The next steps explain how to set up conditions for the clauses, so that the system hides each clause based on the opportunity lead source value..

##### Create a Template

Create below template with multiple clauses and add Tags for each clause as shown below. Follow next steps on how to add tags.

![contract butler conditional clauses pic3](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic3.png)

##### How to set up clause conditions

In order to set up conditions in your contract, follow these steps:

###### Clause Tags

First, add tags to the clauses in the template. After adding tags, they will be shown below the clause text. To do this, hover over the space below the clause text in the Template Builder and click on the tag icon as shown below.

![contract butler conditional clauses pic1](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic1.png)

A modal window will open as shown below, allowing you to add or edit tags for the target clause.

![contract butler conditional clauses pic2](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic2.png)

##### Filtering Subflow: Filter Agreement Placeholders

Next, set up conditions in a Flow. This example describes a subflow with conditional clause logic based on Opportunity object field values. The subflow creates a list of clause IDs and passes it as a parameter to the 'Create Agreement' Flow Action in the 'Create Agreement From Opportunity' flow. This flow is part of the Contract Butler Starter Pack. You can install Contract Butler starter pack [here](https://pdfbutler.com/academy/non-knowledgebase/contract-butler-starter-pack/install-contract-butler-starter-package).

Create a screen flow as below and call it as "Filter Agreement Placeholders". A detailed explanation of how to build this flow is provided in the next steps.

![contract butler conditional clauses pic4](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic4.png)

###### Input parameters:

Create below two input parameters. Pass the values to these parameters from "Create Agreement From Opportunity" flow of starter pack.

opportunity (Record) – source object record,

templateId (Text) – id of the target template.

###### Output parameters:

Create below output parameter.

tagIdsToExcludeResult (Text Collection) – list of clause ids to exclude from the newly created contract.

###### Get template items

At the beginning we need to retrieve all required data, for example in this case Opportunity (input parameter) and Template’s Clauses.

Get Template Items - get list of clauses by Template Id. Contract Instance Item is the object which stores the clauses of a template. So, query Contract Instance Item object records based on cadmus_contract__ContractInstance__c(Agreement template) Id as shown below.
 ![contract butler conditional clauses pic5](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic5.png)

###### Conditional Logic

For conditional logic, we need tag, clause name or text. This part of the flow includes:

- Loop Items - iterate through a list of template’s clauses.
- Items to exclude Decision element – It evaluates a set of conditions based on the clause tag and the state of fields in the target record to determine which clause IDs to add to the exclusion list.
- Items to Exclude Assignment element - add the clause ID to the exclusion list

Loop through template items queried from previous step and add decision element to exclude clause ids based on the logic. In this example, I want to hide the clause where the corresponding tag contains the Opportunity record's Lead Source value. So Create an Outcome under decision element and add the logic as shown below.

![contract butler conditional clauses pic6](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic6.png)

In that Outcome path, add Assignment element as shown below to exclude tag Ids or template items(Clauses) which falls under above mentioned condition.

![contract butler conditional clauses pic7](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic7.png)

Save the flow and activate it.

##### Create Agreement From Opportunity Flow

This flow is part of contract butler starter pack. Install the starter pack from here to make use of this flow.

###### Flow Action: Filter Agreement placeholders

Before the 'Create Agreement' flow action, we need to check whether the system should exclude any clauses from the Agreement/Contract. So add the sub flow element "Filter Agreement placeholders" before the flow action.

![contract butler conditional clauses pic8](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic8.png)

Set the Input and output parameters of the sub flow as shown below.

![contract butler conditional clauses pic9](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic9.png)

###### Flow Action: Create Agreement

The following fields are crucial for evaluating the conditional clause logic in the contract generation process, and you should assign them to the 'Create Agreement Flow' action, as shown in the screenshot below.

templateId – used to retrieve the correct template, including its structure and associated clauses.

itemIdsToExclude – defines the specific template clauses that the system should exclude from the newly created contract.

![contract butler conditional clauses pic14](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic14.png)

##### Testing

Open any opportunity and click on Create Agreement button(This button is part of starter pack). Give the template name and create an agreement.

![contract butler conditional clauses pic10](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic10.png)

Since the Opportunity's Lead Source is 'Purchased List' and we haven't excluded any clauses for this Lead Source, the system includes all clauses in the Agreement/Contract, as shown below.

![contract butler conditional clauses pic11](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic11.png)

Now update the opportunity's Lead Source to "Web".

![contract butler conditional clauses pic12](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic12.png)

Create an agreement, and the agreement/contract will not have the clause text with "Web" as a tag.

![contract butler conditional clauses pic13](https://pdfbutler.com/wp-content/uploads/2025/06/contract-butler-conditional-clauses-pic13.png)

 

 

 

 
