Overview
Box Doc Gen for Salesforce enables teams to automatically generate custom documents directly from Salesforce records using dynamic templates stored in Box. By merging Salesforce data into pre-configured templates, organizations can generate consistent, accurate documents in seconds without leaving Salesforce.
This reduces manual document preparation, eliminates repetitive data entry, and helps teams accelerate business processes such as approvals and contracts. Documents are generated using Salesforce data and Box templates, allowing teams to produce formatted, error-free documents in seconds.
Common use cases include:
Generating sales proposals or quotes from Opportunity data
Creating contracts, agreements, or NDAs from Account or Contact records
Customer onboarding documentation
Automatically generating documents that are sent for signature using Box Sign within Salesforce
Box Doc Gen templates can include fields from the record you're generating from, related child records through nested tables (up to five relationship levels deep), and additional Salesforce data brought in through data sources.
Pre-requisites
Important: The instructions below may vary depending on changes made to the Salesforce interface which is outside of Box’s control.
- You have completed Installing and Configuring Box For Salesforce for your organization. This means:
- The Box Service Account is signed in
- The Box User is signed in, and is a different user than the Box Service Account
- The Box for Salesforce Root Folder exists
- Applicable permissions are assigned to Users
- Your organization is eligible to use Box Doc Gen (please reach out to your Account Manager for more information.)
- Box Doc Gen is enabled in the Box Admin console (Enterprise Settings > Content & Sharing > Box Doc Gen > Edit Configuration)
- After Box Doc Gen is enabled, the Salesforce Admin needs to re-connect the Box Service Account and Box User, to approve the new Doc Gen application scopes.
Note:
- The document generation is by default run by the Box User account, so they require access to the Doc Gen folder under the Salesforce root folder.
- When a user attempts to generate a document, they will automatically be added as a collaborator to both the record folder and the Doc Gen template within Box.
- The document generated is stored in the applicable Box for Salesforce folders.
- Viewing documents and UI elements are run as the specific/standard Box users.
Assign Box Doc Gen Permission Sets
Box Doc Gen for Salesforce enables you to assign specific users in Salesforce to:
- Create and manage the templates used in Salesforce and/or
- Use the templates to generate documents.
To do this, you will need to assign applicable users custom Box permission sets.
As the Salesforce Admin:
- In the Salesforce App Launcher, search for and navigate to Box Settings.
- In the Assign Permissions section, click Assign.
-
For Box Doc Gen Template Manager, click Manage Assignments and manage the permission set for users who will create, edit, or set up Box Doc Gen templates.
Note: This permission set allows these users to see Box Doc Gen and Box Doc Gen Templates from the App Launcher.
- For Box Doc Gen Users, click Manage Assignments to manage the permission set for users who will generate documents in Salesforce.
-
Adding Box Doc Gen Templates to Salesforce
In the Box Doc Gen Templates tab, Box enables users with Box Doc Gen Template Manager permissions to create and manage templates for generating documents. The Box Doc Gen Templates tab displays a list of all available templates, including sObject, status, and folder ID.
As a user with the Box DocGen Template Manager permission set:
- From the App Launcher, search and navigate to Box Doc Gen Templates.
- In the top right corner, click New to launch the template manager.
- While in the Create Template step:
- In Template Name, choose a name for the template in Salesforce
- In Generated File Name, choose the name you want the generated file to be named
- In Object, choose the Salesforce Object associated with the template.
- Click Next.
- In the Download JSON step:
- Click Download JSON File to download a file named {ObjectName}DocGen.json. This is used to pull the tags into the Microsoft Word Add In .
- Click Next.
- Create and edit your template in the Box Doc Gen Template Creator, Microsoft Word Add-in. (See next step)
- In the Upload Template step:
- Attach your template as a docx or pdf file.
- Click Upload.
- Once the upload is complete, click Next.
- (Optional) In the Preview step, test your template on a sample record.
- In Sample Record, search and select the record you would like to test your template on.
- Click Preview.
- Click Next.
- In the Settings step, you can finalize the template settings:
- Check the Available for Box Sign checkbox to make it available for approval and signature.
- In Output type, choose the desired file type to be generated.
- Click Save and Finish.
On completion, the Box Doc Gen Template tab displays the following tabs:
- Details — the template's settings and previous jobs run.
- Template — a preview of the template file stored in Box; if saved as DOCX, you could edit the template as a Word document later at any time.
- Tags — the Doc Gen Template Tagger, plus a list of every tag currently in the template.
- Data Sources — any additional data sources configured for this template.
- Preview Payload — the exact data that would be merged into a document for a sample record.
Creating a Template with the Box Doc Gen Template Creator in Microsoft Word
To create and edit Box Doc Gen templates, Box recommends using the Box Doc Gen Template Creator Word Add-in. For more information on how to create a Box Doc Gen template, see here.
To begin using Salesforce tags in the Box Doc Gen Template Creator, you will first need to import the tags. To import tags:
- Open the file that will be your template in Microsoft Word, and open the Box Doc Gen Template.
- Click Start with your data.
- Upload the json file you previously downloaded.
- Click Generate tags.
- Search and select the appropriate fields to build your own template. The tags are displayed next to your cursor.
Building Templates with the DocGen Template Tagger
Box Doc Gen templates can include related child-record data — not just the fields on your starting record — through nested tables. The Doc Gen Template Tagger is the guided, point-and-click way to generate tags for nested tables, as well as for fields, conditions, and calculations.
With the Tagger, you can:
- Browse the fields of the template's object and its parent (lookup) records, its child relationships, the current user, the organization, and any active data sources
- Generate a correct, ready-to-paste Box Doc Gen tag for any field, nested table (up to five relationship levels deep), condition, or calculation.
- Copy the generated tag straight to your clipboard, with a confirmation showing exactly what was copied.
- Check tags against a sample record and catch errors before you generate a document.
The DocGen Template Tagger is a tag generator, not a document editor. You still lay out your document in Word using the Box Doc Gen Template Creator Add-in, and paste in the tags the Tagger generates for you.
To generate tags with the Doc Gen Template Tagger:
- Open your Box Doc Gen Template record and go to the Tags tab.
-
(If Data Sources active) In Sample record, select a record to test tags against as you build them. If the template has data sources, click Generate data source tags to include their tags as well.
Note: Tags are based on the sample record you select. Because data source results can change from record to record, other records may include tags that aren't shown here.
- Use the four tabs to generate the kind of tag you need:
- Tags — browse fields on the object, the current user, the organization, and any active data sources. Expand a field to reach fields on its parent records. Select a field to copy its DocGen tag.
- Tables — select a Child Relationship, then optionally drill into that relationship's own child relationships (Level 2 through Level 5). Under Select Columns, select the fields you want as table columns, then click Generate Table Tag.
-
Conditions — generate
{{if}} ... {{endif}}tags, so that content between them only appears when a condition is met. - Calculations — generate calculation tags, for example arithmetic on a numeric field.
- Paste the copied DocGen tag into your Word template, the same way you would any other tag.
The Tags in Template panel on the right lists every tag already in your template file. Use Session Tags to find a recently created tag and click the copy icon to copy it again.
Building a nested table tag
On the Tables tab, each relationship level appears once the previous level is selected, and the full relationship path is shown as you build it (for example, Opportunity.Invoices.InvoiceLines).
When you click Generate Table Tag, the full {{tablerow ...}} ... {{endtablerow}} block is copied to your clipboard. Every tag you generate is also added to Session Tags, so you can re-copy it while building a larger template.
Notes:
- Nested tables iterate over child relationships, up to five levels deep from the template's object.
- To use a field from a parent (lookup) record, such as
{{Opportunity.Account.Name}}, use the Tags tab instead.
Catching tag errors before generating a document
If a tag in your template references a relationship or field that doesn't exist on the object, the Tagger highlights it in red in the Tags in Template panel. Expand the tag to see the error (for example, "Relationship Contact__r does not exist on Opportunity") and the value for your sample record. This lets you fix the tag before you generate a document.
Going Further: Data Sources
If the data you need isn't available from your record's own fields or its related records — for example, the results of a custom SOQL query, images stored in a Box folder, or data built by Apex or a Flow — you can add a data source to your template. Each data source merges its data into the document under its own alias, and its tags appear in the DocGen Template Tagger alongside your record's fields.
Data sources are created from the Box Doc Gen Data Sources tab in the App Launcher. To see the full data that would be merged into a document for a sample record, including all active data sources, open the Preview Payload tab on the template, select a Sample record, and click Preview payload.
For full setup instructions, see Using Data Sources.
Adding and Displaying the Box Doc Gen button in Objects
Before your users can generate documents, you need to create a button and add it to your applicable Object page(s).
- Navigate to Setup by clicking on the gear icon in the top-right hand corner of your Salesforce instance.
- In the upper-left, navigate to Object Manager tab.
- Select the Object(s) where you want to add the button for your users to generate documents.
- Go to Buttons, Links, and Actions in the left-hand side-bar.
-
Click New Action from the upper right corner.
- In the Action Type dropdown, select Lightning Component.
- In the Lightning Component dropdown, select “box:dgRecordPage”.
- In the Label field, type in the name you want to call your Button (example: “Generate Doc”)
- Optionally, edit the pre-populated field (without spaces.)
- Optionally, change the Icon to a different logo.
- Once complete, click Save.
Once you’ve added the Box Doc Gen button to the applicable Object(s), you can begin editing the pages where you want to add the Box Doc Gen button.
- From Salesforce Object Manager, in the applicable Object(s), navigate to Page Layouts.
- Select the applicable Page Layout.
- Select Mobile and Lightning Actions.
- From the palette, find the Box Doc Gen button you have created, and drag it down to the desired position in Salesforce Mobile and Lightning Experience Actions. (Box recommends hovering your cursor over the button to confirm it is the created Box button. There is also a standard button named Generate Document.)
- Click Save.
Setting up Batch Doc Gen
You can also enable users to generate documents for multiple records for a given object at once, from a Salesforce List View. First create a button and add it to your applicable List View(s).
First, create the Batch DocGen button:
- Navigate to Setup..
- Navigate to Object Manager, nested under Objects.
- Select the Object(s) where you want to add the button for your users to generate documents.
- In the left-hand side-bar, go to Buttons, Links, and Actions.
-
In the upper right corner, click New Button or Link.
- In Label, select a label to call your Button
- In Name, select a Name (or edit the pre-populated Name field - without spaces)
- For Display Type, select List Button
- Populate the formula with “/flow/box/Generate_Box_Documents?retURL=001/o”
- Click Save.
Notes:
- retURL will be specific to the object type.
- "Enable Lightning runtime for flows" in Process Automation Settings is required.
After you create the Batch DocGen button, make an Object's List View to be viewable to your users.
To edit an Object's List View:
- In the Object manager, select the Object where you want to add the List View button.
- In the left-hand sidebar, navigate to List View Button Layout.
- In the List View row, click the dropdown then Edit.
- Scroll to the Custom Buttons section, select the newly created button and click the Add arrow to add the button.
- Click Save.
Now the button is available in your users’ List views.
(optional) Additional Customization
Administrators and developers can customize document generation and other Box workflows using Salesforce Flow Actions provided by the Box for Salesforce Developers toolkit.
Box Doc Gen Flow Actions
Box provides several Flow Actions specifically for document generation workflows, including:
Create Doc Gen Template (
createDocGenTemplate) – Create a new document generation template.Generate Doc Gen For Record (
generateDocGenForRecord) – Generate a document for a specific Salesforce record.Submit Doc Gen Batch (
submitDocgenBatch) – Generate documents for multiple records in a batch process.Get Doc Gen Batch Status (
getDocgenBatch) – Retrieve the status of a batch document generation job.
When using Flow Actions from the Box for Salesforce toolkit, administrators can configure operations to run using the Box Service Account rather than the currently logged-in Salesforce user.
Running actions as the service account can be useful for:
Allowing automated processes to access Box content even if the triggering user does not have direct access
Centralizing content management under the integration service account
Related Articles
- Installing and Configuring Box for Salesforce
- Box Doc Gen in Salesforce - Using Data Sources
- Box Doc Gen in Salesforce - FAQ
- Generating documents in Salesforce