Help Center / Contacts and CRM /
Show or hide text with if/else
An if/else condition shows a piece of text only when a variable has a value, and other text when it doesn't. So one proposal, contract or invoice template reads right for every client, whether or not their company name, phone number or project is filled in.
Where conditions work
Conditions work anywhere variables work in text you write:
- text blocks and intro blocks of proposals, contracts and invoices, and the templates they come from
- emails and messages sent by automations
Type the condition straight into the text. The Variables button in the editor toolbar inserts the variable itself, for example {{client.company.name}}, and the condition goes around it.
Show text only when a variable has a value
Put the text between {{#if variable}} and {{/if}}:
Hi {{client.firstName}}{{#if client.company.name}} from {{client.company.name}}{{/if}},
For a client at Bob's Deli, the line reads "Hi Anna from Bob's Deli,". For a client with no company, it reads "Hi Anna,". The words "from" and the company name disappear together, so no half sentence is left behind.
Show other text when it's empty (else)
Add {{else}} to give the text to show when the variable is empty:
{{#if project.name}}Project: {{project.name}}{{else}}This agreement covers the work described below.{{/if}}
A document linked to a project shows the project's name. A document without a project shows the sentence after {{else}}.
Show text only when a variable is empty (unless)
{{#unless variable}} is the opposite of {{#if}}: its text shows only when the variable is empty. It takes an {{else}} too:
{{#unless invoice.paidDate}}Payment pending{{else}}Paid on {{invoice.paidDate}}{{/unless}}
What counts as empty
A variable counts as empty when it has nothing in it: an empty field, a client with no company, a document with no project.
A variable that's empty and not inside a condition stays in the document as its raw text, for example {{client.phone}}. Wrapping it in {{#if client.phone}}…{{/if}} hides it instead.
What conditions can't do
- Check what the value is. A condition only checks whether a variable has a value. It can't check which value, for example whether the client's country is France.
- Check two variables at once. Each condition checks one variable. Two optional details get a condition each, written side by side.