> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/job-splitters.md).

# Job Splitters

{% hint style="warning" %}
This page applies only to **Visualforce** and **SDJobs** document generation.

**Do not use job splitters unless instructed by S-Docs.**
{% endhint %}

## 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

{% stepper %}
{% step %}

#### 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.
{% endstep %}

{% step %}

#### 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.
{% endstep %}

{% step %}

#### 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.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Common errors** that can be resolved with job splitters are **“Regex too complicated”** and **“Apex CPU time limit exceeded”**
{% endhint %}

### 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.

```
<splitEvery> 5 </splitEvery>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/job-splitters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
