For the complete documentation index, see llms.txt. This page is also available as Markdown.

Job Splitters

What are Job Splitters

  • A special merge field, {{!JOB_SPLITTER}}, that allows a template to be split into chunks when it is generated in order to avoid various Salesforce limitations

Considerations for {{!JOB_SPLITTER}}

When implementing {{!JOB_SPLITTER}} tags, it's crucial to carefully identify complex elements in the template source code to determine optimal placement. This includes:

  • Queries (e.g., related lists)

  • Conditional logic (RENDER statements)

  • Styling elements (such as images and smart formatting in DOCX)

Key Things to Note

1

Base Placement in Source Code

It's important to underscore the need for placing job splitters directly in the base HTML source code. Tags or logic split across multiple transactions are prone to failure. Therefore, it's essential to add efficiencies from the backend to avoid disrupting any existing HTML structures. Front-end placements should be considered less precise and should be avoided when possible.

2

Avoid Nested Placement

{{!JOB_SPLITTER}} tags should never be placed inside other HTML elements like <table>, <div>, <span>, <lineitems>, or RENDER blocks. This rule also applies to component templates where parent HTML structures must be factored in.

3

Limit the Number of Job Splitters

It's important to use job splitters judiciously. While Apex jobs have complexity limits, the Apex job queue also has restrictions, and each {{!JOB_SPLITTER}} increases the number of jobs added to the queue. Using too many splitters can reduce overall efficiency, as breaking processes into too many asynchronous transactions may end up taking longer than if fewer job splitters were applied. Striking the right balance is key to optimizing performance.

Common errors that can be resolved with job splitters are “Regex too complicated” and “Apex CPU time limit exceeded”

Adding job splitters using the tag

The following line of code breaks up the processing of Component Queries into chunks of 5 records at a time. The above considerations for the Job Splitter merge field also apply to this tag.

Last updated

Was this helpful?