Skip to main content

Discover Client-Side Document Generation

Learning Objectives 

After completing this unit, you’ll be able to:

  • Explain three ways of passing data into a document template.
  • Describe elements of the client-side OmniScript sample.

Building Document Generation Processes

You’ve seen Felix, our Salesforce administrator, create the perfect document templates for Sophia and her team. Illustration of Felix building the document templates

He built Web templates and Microsoft Word and PowerPoint templates, inserting tokens in all the right places. Felix imported the templates into the Document Template Designer in Salesforce, defined the configuration, and tested the templates to ensure they work flawlessly. Now you might be wondering: How does he embed the document templates into a business process so that Sophia’s team can use them?

All documents in Industries Document Generation are created by passing JSON input data into a template, which Felix created earlier. An OmniScript or custom class can provide the JSON input data, or the template can extract the data using the specified Data Mappers. 

  • Whenever a user interaction is required, for example, if a sales rep needs to fill out a form to generate a document, use the client-side document generation processes.
  • If you want to automate the process, for example, to generate a document in response to a trigger, or if you have a large document, use server-side document generation.

Let’s dive deeper into client-side document generation.

Passing Data into a Document Template

You have three ways to pass data into your document template in client-side document generation. 

  • Customize the sample OmniScript provided.
  • Create a new OmniScript.
  • Use JSON input.

Customized Sample Client-Side OmniScript

Industries Document Generation includes a sample OmniScript that guides you through the process of generating a document. 

Sample Client-Side OmniScript preview

The OmniScript presents steps to collect required details, such as Object Id and document-formatting options. The last step shows a preview of the generated document for download. 

The sample OmniScript is generic, so you can customize it to fit your use case. To use the sample with your document template, make sure your template has a Data Mapper Extract and a Data Mapper Transform because the OmniScript sample doesn’t extract Salesforce data for the document. You set up the Data Mappers in the previous unit using the Document Template Designer. 

User Data Collection with OmniScript

To generate documents, you can also use a separate OmniScript that collects user data to pass into the document template. For example, a car insurance policy OmniScript asks the customer for their name, birthdate, address, and car details. The OmniScript then passes the data into the template. Because the OmniScript already contains Data Mappers or Integration Procedures, the template only requires a Data Mapper Transform and not a Data Mapper Extract, like the previous example. 

Custom Class JSON Input 

For documents with lots of data, for example, more than 200 line items, you can use a custom Apex class to extract the data and generate the JSON input. This way, you don’t need an OmniScript or Data Mapper Extract. To use this method, connect your custom Apex class to the document template in the Document Template Designer. 

Document Generation OmniScript Sample

One of the easiest ways to get up to speed with Industries Document Generation is to use the sample OmniScript. This is what Felix uses to create document generation processes for the Infiwave sales team. He uses the sample to test the template or as a starting point for building his own OmniScript. Then end users can launch the OmniScript from a record page to generate a document. 

Find the sample OmniScript in the OmniScript tab under the name: docGenerationSample/SingleDocxLwc. 

Felix creates a new version of the sample OmniScript. He uses his version as the starting point for a new document generation OmniScript. This way, the original sample OmniScript remains intact and he can use the original to create other OmniScripts later on, as needed.

Let’s learn about the elements of the OmniScript sample and follow Felix as he customizes it for his use case. The sample client-side document generation OmniScript includes several steps, which run sequentially when the OmniScript is invoked.

Click the plus-icon (+) hot spots on the image to learn more.

Client-side document generation is a great option for business processes that require user interaction and for generating smaller documents. In the next unit, you learn about server-side document generation and all the goodness it has to offer.

Resources 

在 Salesforce 帮助中分享 Trailhead 反馈

我们很想听听您使用 Trailhead 的经验——您现在可以随时从 Salesforce 帮助网站访问新的反馈表单。

了解更多 继续分享反馈