Summary
Large Word documents can fail when generated through DocGenGiantQueryFlowAction, even though this action is intended to handle large datasets automatically.
Error
System.LimitException: Apex heap size too large: 7126369
Environment
- Portwood version: 3.56
- Template type: Word
- Execution method: Generate Document (Auto Giant Query) Flow action
- Save to Record: Enabled
Current behavior
Smaller Quotes generate successfully, but larger Quotes fail immediately with an Apex heap-size error.
The action only switches to asynchronous Giant Query processing when a child relationship exceeds 2,000 records. A Quote with fewer records can still exceed the 6 MB synchronous heap limit when its records contain large descriptions, rich text, many queried fields, or other substantial data.
Some template preparation also occurs before the background batch starts, so the synchronous transaction can fail before asynchronous generation begins.
Expected behavior
The Auto Giant Query action should detect memory-heavy documents and move generation to background processing before Salesforce’s synchronous heap limit is reached.
Proposed solution
- Start Auto Giant Query generation in a background transaction.
- Move template loading and child-record analysis out of the original Flow transaction.
- Consider payload size as well as record count.
- Process large child datasets in smaller batches.
- Return a Job ID and generation status to the Flow.
- Show a helpful message instead of exposing a raw
System.LimitException.
Acceptance criteria
- Large Quotes below the 2,000-record threshold do not fail with a synchronous heap error.
- Large Word templates are not fully processed in the original Flow transaction.
- Large documents automatically use background or batched generation.
- Small Quotes continue to generate normally.
- The completed document is saved to the requested record.
- Users receive a clear status or actionable error message.
Additional note
This is a heap-limit issue and is different from the Regex too complicated problem tracked in #325 / PR #341.
Summary
Large Word documents can fail when generated through
DocGenGiantQueryFlowAction, even though this action is intended to handle large datasets automatically.Error
System.LimitException: Apex heap size too large: 7126369Environment
Current behavior
Smaller Quotes generate successfully, but larger Quotes fail immediately with an Apex heap-size error.
The action only switches to asynchronous Giant Query processing when a child relationship exceeds 2,000 records. A Quote with fewer records can still exceed the 6 MB synchronous heap limit when its records contain large descriptions, rich text, many queried fields, or other substantial data.
Some template preparation also occurs before the background batch starts, so the synchronous transaction can fail before asynchronous generation begins.
Expected behavior
The Auto Giant Query action should detect memory-heavy documents and move generation to background processing before Salesforce’s synchronous heap limit is reached.
Proposed solution
System.LimitException.Acceptance criteria
Additional note
This is a heap-limit issue and is different from the
Regex too complicatedproblem tracked in #325 / PR #341.