Conditional content allows you to customize your Google Docs template and generate different versions of the same document based on the user’s answers. In this tutorial, I’ll show you how to use conditional content in Google Docs using Document Studio, a Google add-on that automates document creation.

If you are new here, please follow this step-by-step guide on how to generate documents from data in Google Sheets and Google Forms responses.

Conditionally Display Content

Job Candidates in Google Sheets

Let’s say you are a recruiter who wants to use a Google Docs template to send out job offer letters to candidates. You want to include specific information in the offer letter based on the candidate’s job title and location.

The conditional statements that we would like to include in the document template are:

  1. Your office is located in San Francisco. Your offer letter should include a paragraph offering relocation benefits only to candidates who are located outside SF.
  2. If the candidate is offered an Associate position, they are eligible for basic benefits.
  3. If the candidate is hired for a senior position, like Manager or Director, they are entitled to additional benefits like 401(k) retirement plan.

Define the conditional sections

Create a new Google Docs document and create a job offer letter template. Include sections for the candidate’s name, job title, location, salary, and benefits package.

Conditional Logic in Google Docs

Use the <<if>> and <<endif>> expressions to define the conditional sections in your template. For example, you might use the following expressions to show or hide the relocation package section based on the candidate’s location:

<<If: ({{Location}} != 'San Francisco')>>
We are pleased to offer you a relocation package to assist with your move from {{Location}} to our main office.
<<EndIf>>

Similarly, you can wrap the benefits paragraph with the <<if>> and <<endif>> expressions to show or hide the benefits package section based on the candidate’s job title:

<<If: OR (({{Job Title}} == 'Manager'), ({{Job Title}} == 'Director'))>>
As {{Job Title}}, you will be eligible for our comprehensive benefits package, which includes health, dental, and vision insurance, a 401(k) retirement plan, and more.
<<EndIf>>

You may also use the ~ contains operator in place of == equals operator for partial matches. For instance, {{Job Title}} ~ 'Manager' will match Sales Manager, Senior Manager, Manager and so on.

Here’s how the final job offer letter template looks like.

Play ;

In addition to document templates, you can also add conditional text in email templates with the help of scriptlets.

Things to know:

  1. You may not nest IF statements inside each other.
  2. You can use the OR, AND or NOR operator to combine multiple conditions.
  3. If you have a table in your document that should be displayed conditionally, you should put the wrapping <<if>> and <<endif>> tags outside the table.
  4. It is currently not possible to hide or show specific rows or columns of a table based on the user’s answers.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Author

prakhar@affmantra.com

Related Posts

How to Handle OAuth Permissions in Google Add-ons

Table of Contents 1. How to Check for Required OAuth Scopes 1.1 The “Authorization Catch-22” Problem 1.2 How to Reset the Permissions...

Read out all

How to Recover Permanently Deleted Files and Folders in Google Drive

Table of Contents When you delete any file or folder in your Google Drive, it is moved to the trash folder. The...

Read out all

Simple URL Tricks for Google Drive You Should Know

Table of Contents 1. Google Drive URL Tricks 1.1 Google Drive Web Viewer 1.2 Reader Mode for Google Drive Files 1.3 Embed...

Read out all

How to Extract URLs from HYPERLINK Function in Google Sheets

The HYPERLINK formula of Google Sheets lets you insert hyperlinks into your spreadsheets. The function takes two arguments: The full URL of...

Read out all

Find and Remove Inactive Users in your Google Workspace Domain

Table of Contents 1. Find the inactive users in Google Workspace domain You can use Google Apps Script to find all the...

Read out all

The Best Online Tools To Know Everything About a Website

The Best Online Tools To Know Everything About a Website Source link

Read out all