The HotDocs Document Templates tab is where you manage the connection between your HotDocs templates and Salesforce objects. Each record you create here defines a "mapping", which tells the integration which Salesforce fields should populate the variables in a specific HotDocs template.
HotDocs Document Templates Tab
This tab provides a list view of all existing template mappings in your organization. From this view, you can:
- Access your saved list views for the HotDocs document template.
- Create a New HotDocs document template.
- Create, delete, or edit the available list views for the HotDocs document template.
- Access, delete, or edit the available HotDocs document template from the list.
Creating or Editing a HotDocs Document Template
When you click New or Edit an existing record, an editable form appears where you can configure the mapping.
This is the primary setup section for the mapping.
- Name: A friendly name for your template mapping (e.g., "Sample Employment Agreement").
- Description: An optional description for the template mapping.
- Object: The Salesforce object that this template will be available for (e.g., Account, Contact, Matter).
- Record Type: If the selected object uses record types, you can specify one to make this template available only for records of that type.
- Active: Check this box to make the template mapping available for users.
- Select HotDocs Template: This button opens a modal that allows you to browse your HotDocs workgroups and select the specific template you wish to map.
Refreshing Your Template Mapping Version
The Select HotDocs Template button always retrieves the latest published version of a template. If you have updated a template in HotDocs Advance, you can edit its mapping in Salesforce and re-select the same template. This will refresh the variable list with any new additions without destroying your existing field mappings.
This section lists all the variables found in your selected HotDocs template. Your task is to map each variable to a corresponding field in Salesforce.
- Template Variable Name: The name of the variable from the HotDocs template.
- Variable Type: The data type of the variable (e.g., Text, Number, Date, Boolean).
- Mapped Field: This input is where you define the source of the data. Based on whether the variable is of a repeat nature, the input control displayed will allow the user to select a related object.
- Field Mapping: For simple variables (Text, Number, Date), click the
</>insert merge button icon to map a variable to a field on the primary object (e.g., the Account record), click the field picker icon, and select the desired field. You can also access fields on parent records (e.g.,{{Parent.Owner.FirstName}}).
- Related Object Mapping: For table or repeat variables, click the Select Related Object button. This allows you to choose a related list (e.g., Contacts, Cases) to populate with repeating data (such as a list of cases or contacts for an account).
- After selecting a related object, you can map each column of the repeating data to a field on that related object.
- You can also apply filters to the related data. For example, you can specify that only Contacts where the "Account" equals "Acme" and "Priority" equals "Medium" should be pulled into the document.
- After selecting a related object, you can map each column of the repeating data to a field on that related object.
- Field Mapping: For simple variables (Text, Number, Date), click the
- Sorting: Use the menu to sort the list alphabetically by variable name or type.
- Quick Filters: Use the search box to filter the list by variable name. You can also use the type dropdown to show only variables of a specific data type (e.g., Text, Date, Table).
- Quick Add: If you need to add a variable that isn't in the list, use the "Add Variable" fields at the bottom. Enter the exact variable name, select its type, and click Add to include it in the mapping grid.
Manually Adding Variables
If you know a variable's exact name and type, you can add it manually using the Quick Add section available in the footer of the Template Variables Mapping grid.
HotDocs Document Template Sync Status
The Template Sync Status field on HotDocs Document Template indicates whether the mapped template in Salesforce is aligned with the latest version available in your HotDocs Advance library. A background job can be scheduled to run periodically to check for newer published versions of your mapped templates.
Possible values in this field are:
- Up-to-date: The mapping is using the latest published version of the template.
- Out of date: A newer version of the template has been published in HotDocs. You should edit this mapping and re-select the template to update its version and variables.
- Unknown: The template version is no longer available in HotDocs Advance.
Scheduling the Template Sync Apex Job
For the sync status to be updated automatically, a Salesforce administrator must schedule the background Apex job. You can do this in one of two ways:
This is the simplest method, but it requires a manual step before upgrading the package in the future.
Steps to Schedule:
- Navigate to Setup > Apex Classes.
- Click the Schedule Apex button.
- Configure the job schedule:
- Job Name:
HotDocs Template Version Sync - Apex Class: Search for and select the class named
HotDocsTemplateVersionSyncSchedulable. - Frequency: Choose your desired frequency (e.g., "Daily").
- Preferred Start Time: Select a time during off-peak hours (e.g., 2:00 AM).
- Job Name:
- Click Save.
This method locks the Apex classes for package upgrades. Before upgrading this package in the future, you must first go to Setup > Scheduled Jobs, find this job by its name, and delete it. After the upgrade is complete, you can return here and reschedule it.
This method is recommended as it prevents the job from locking the Apex classes during an installation, making package upgrades smoother.
Steps to Schedule:
- Navigate to Setup > Developer Console.
- In the Developer Console, click Debug > Open Execute Anonymous Window.
- Paste and execute the following code.
String jobName = 'HotDocs Template Version Sync';
// This is a CRON expression that defines the job's schedule.
// It consists of 6 parts: Seconds Minutes Hours Day_of_month Month Day_of_week
// The example below runs at 2:00 AM every day.
// You can customize this. For example, '0 0 3 ? * MON-FRI' would run at 3:00 AM on weekdays.
String cronExpression = '0 0 2 * * ?'; // This schedules the job to run daily at 2:00 AM.
System.schedule(jobName, cronExpression, new hdocs.ScheduleDispatcher(hdocs.HotDocsTemplateVersionSyncScheduler.class));


