Transform Token Data with Context Service for Document Generation
Reshape and enrich token data before document generation by using a transform plug-in
to apply Apex logic. You can build hierarchies, group related records, or perform custom
calculations that the context service alone can’t handle. You can use a transform plug-in in
conjunction with a context filter. Document generation applies the template’s context filter
before running the transform plug-in.
Required Editions
Available in: Lightning Experience
Available in: Professional, Enterprise, Unlimited, and
Developer Editions
When to Use the Transform Plug-In
Use the context service transform plug-in when you want to:
How the Transform Plug-In Works with Document Generation
When you generate a document by using context service, it evaluates the context definition
and mapping. If configured, applies the selected context filter, and fetches the token data.
Document generation then calls the transform plug-in, which returns transformed token data
that document generation uses to populate the template. Filters always apply before
transformation. The transform plug-in runs only when the context service is the token
mapping method, and document generation uses the transformed output to populate the
template.
Scope, Support, and Consideration
Use a transform plug-in only when the context service is the token mapping method.
Associate only one transform plug-in with a document template.
Run transform logic in Apex without modifying Salesforce data.
Configure advanced transformations in code because the template designer UI doesn’t
expose transform plug-ins.
Account for Apex governor limits because the transform logic runs in Apex.
Limit token payload size because large payloads can degrade performance or cause
document generation to fail.
Build all transformation logic by using token data returned by the context service
because transform plug-ins don’t accept custom input parameters.
Control document output through the template and include repeater tokens for each
hierarchy level you want to render.
Note Omnistudio document generation doesn’t support
context service transform plug-ins.
Create a Context Service Transform Plug-In Build hierarchies, group related records, or perform custom calculations by creating a custom Apex class that transforms token data before document generation.
Associate a Transform Plug-In with a Document Template Configure a document template to use a custom Apex transform plug-in during document generation. Document generation calls the transform plug-in automatically at run time.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required Cookies
Always Active
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional Cookies
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising Cookies
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.