Document generation often pulls data from complex models that return more records than
a document requires. To exclude irrelevant data, use filters to control which data the context
service fetches before generating a document. When you add a filter to a template, document
generation applies the filter every time a document is rendered.
Required Editions
Available in: Lightning Experience
Available in: Professional, Enterprise, Unlimited, and
Developer Editions
You define context filters in a context definition. Each filter belongs to a single context
definition and becomes available automatically when you use that context definition in a
document template. Filters are optional. If you don’t select a filter, document generation
uses all records returned by the context definition and mapping.
What Context Filters Do
A context filter can refine data in three ways:
Filter records by using defined conditions
Sort records by a single attribute
Limit records returned after sorting
Context filters operate on context nodes and attributes, not directly on Salesforce object
fields. These nodes and attributes come from the canonical structure defined in the context
definition. All filter conditions use AND logic. The UI doesn’t support OR conditions and
complex expressions that combine multiple condition types.
How Context Filters Work with Document Generation
When you generate a document by using context service, it evaluates the context definition
and token mapping. It then applies the selected filter and passes the filtered token data to
document generation to populate the template.
Note If a filter references an unmapped attribute, document generation fails at run
time.
You can create context filters to refine line items included in a document. For example,
you can:
Filter quote line items based on quantity or price thresholds.
Sort filtered items in descending or ascending order.
Limit the output to the most relevant records for the document.
When you generate the document, only the filtered and sorted line items appear. The
template layout doesn’t change. Only the data passed into the template changes.
Scope and Support
You can select only one context filter per document template.
Filters apply only to future document generations.
Filters don’t modify Salesforce data.
Document generation supports context filters only when the context service is the token
mapping method.
Document generation in the Omnistudio managed package doesn’t support context service or
context filters.
Apply a Context Filter for Document Generation Apply a filter to a template to control which data the context service fetches each time the template is used to generate a document. A context filter can refine data by applying defined conditions, sort records by a single attribute, or limit the number of records returned after sorting.
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.