# Job Splitters

How to use JOB\_SPLITTERS and various usage considerations.

## 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 into chunks of 5 records at a time.

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

{% hint style="info" %}
The following article explains job splitters in more detail.\
<https://www.sdocs.com/resources/documentation/mass-merge-batch-document-feature/>
{% endhint %}

## Related articles

Error rendering macro 'contentbylabel' : CQL was parsed but the search manager was unable to execute the search. Error message: com.atlassian.confluence.api.service.exceptions.scale.SSStatusCodeException: There was an illegal request passed to XP-Search Aggregator API : HTTP/1.1 403 Forbidden


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
