Post Flow API Field Usage
Use the Post Flow API field on a Viewer template to start an Autolaunched Flow after a document is generated successfully. This gives you a declarative way to run follow-up automation such as notifications, record updates, Chatter posts, or external sync logic.
Overview
The PostFlowAPI__c field is stored on the viewer2__Template__c object. You can use it to:
- Run a Flow automatically after document generation
- Limit Flow execution by context using Salesforce Quiddity values
- Pass document, record, and template IDs into the Flow
- Extend document workflows without custom UI changes
When document creation succeeds, Viewer reads the PostFlowAPI__c field, checks the current execution context, and starts the configured Autolaunched Flow if the context matches one of the allowed Quiddity values.
Quick reference
Name meaning
- Post Flow API = the template field that tells Viewer which Flow to run after document generation
- Quiddity = the Salesforce execution context, such as Aura, Visualforce, REST, Queueable, or Batch Apex
- Autolaunched Flow = a Flow without screen elements that runs in the background
Field format
The field uses a semicolon-separated format:
[namespace__]FlowAPIName;Quiddity1;Quiddity2;...
Format rules
- The first segment is the Flow API name
- The remaining segments are allowed Quiddity values
- The value must contain at least one semicolon
- Flow names and Quiddity values are case-sensitive
- Avoid spaces around semicolons
- Total length must stay within 255 characters
Valid examples
SendNotification;AURA
UpdateRelatedRecords;AURA;VF;INVOCABLE_ACTION
c__DocumentProcessor;AURA;SYNCHRONOUS
CallExternalAPI;SYNCHRONOUS;REST;FUTURE
myns__BatchProcessor;BATCH_APEX;QUEUEABLE
Invalid examples
MyFlow
;AURA
MyFlow;
MyFlow;INVALID_CONTEXT
How the value is interpreted
Flow API name
The first value before the first semicolon is the Flow API name.
- For an unmanaged Flow, use the Flow name only
- For a namespaced Flow, include the namespace prefix
MyFlow;AURA
myns__MyFlow;AURA;VF
Quiddity values
Each value after the Flow name defines a context where the Flow is allowed to run.
Common values from the source guide include:
| Quiddity | Typical use |
|---|---|
AURA | User-initiated generation from Lightning or Aura pages |
VF | User-initiated generation from Visualforce pages |
SYNCHRONOUS | Synchronous web-service generation |
REST | REST API generation |
FUTURE | Future method processing |
QUEUEABLE | Queueable Apex jobs |
BATCH_APEX | Batch Apex jobs |
SCHEDULED | Scheduled Apex jobs |
INVOCABLE_ACTION | Flow or Process action generation |
ANONYMOUS | Anonymous Apex testing or debugging |
Required Flow inputs
Your Flow must be an Autolaunched Flow and must include these input variables.
| Variable | Type | Available for Input | Purpose |
|---|---|---|---|
newFileId | Text | Yes | The generated ContentVersion ID |
recordId | Text | Yes | The source business record ID |
templateId | Text | Yes | The template record ID |
Use the exact variable names from the source guide:
newFileIdrecordIdtemplateId
If the Flow uses different names, Viewer will not pass the values correctly.
How to configure it
1. Create the Autolaunched Flow
Create an Autolaunched Flow with no screen elements.
Add these three Text variables and mark all of them as Available for Input:
newFileIdrecordIdtemplateId
2. Update the template
Open the Viewer template record and set the Post Flow API field.
Example:
PostDocumentFlow;AURA;VF
3. Test document generation
Generate a document from that template and confirm:
- the Flow starts
- the current execution context matches one of the configured Quiddity values
- the Flow receives all three input variables
Practical examples
Update the generated file name
Use this when the final file name must be built from the source record and the template in a way that a simple formula field cannot handle.
RenameGeneratedFile;AURA;VF;INVOCABLE_ACTION
What the Flow can do:
- use
recordIdto get the source record values - use
templateIdto get the template name or category - use
newFileIdto find the generatedContentVersion - build a more complex final file name, such as combining record data, template data, and conditional logic
- update the generated file metadata after the file is created
Example scenario:
- file name should include the Account name, document type, template name, and a conditional suffix
- naming rule is too complex for a single Salesforce formula field
Email the generated file after generation
Use this when the file should be sent automatically as soon as it is created.
EmailGeneratedFile;AURA;INVOCABLE_ACTION
What the Flow can do:
- use
newFileIdto get the generated file - use
recordIdto get the recipient or related business context - use
templateIdto choose email logic based on the template used - send the generated file immediately after document creation
Update the source record
Use this when generating a proposal should update a status field and create a follow-up task.
UpdateOpportunityStage;AURA;VF;INVOCABLE_ACTION
What the Flow can do:
- use
recordIdto update the Opportunity - mark the proposal as generated
- create a task for follow-up
Call an external integration flow
Use this when a generated document should trigger an external sync.
dms__SyncToExternalDMS;SYNCHRONOUS;REST
What the Flow can do:
- use
newFileIdto look up the new file - use
templateIdto identify which template created it - route metadata to another system
Validation checklist
The field value should:
- include a Flow name before the first semicolon
- include at least one Quiddity value after the Flow name
- use valid Salesforce Quiddity names
- stay under 255 characters
- avoid extra spaces around delimiters
Best practices
- Use descriptive Flow names that show the business purpose
- Keep post-document Flows lightweight and efficient
- Add fault paths for update, create, and action elements
- Test each configured Quiddity context separately
- Log enough detail for troubleshooting, but avoid exposing sensitive data
More practical guidance from the source guide:
- avoid SOQL in loops
- handle null values before using variables
- document why each Quiddity value is included
- consider async processing for heavier logic
- do not let post-processing errors silently disappear
Common questions
How do I know which Flow type to use?
Use an Autolaunched Flow. Screen Flows are not appropriate for this field.
What happens if the Flow name is correct but the Flow does not run?
Common causes include:
- missing semicolon in the field value
- the current Quiddity does not match the configured values
- the Flow is inactive
- the Flow API name does not match exactly
What happens if the Flow starts but fails?
Common causes include:
- missing required input variables
- variable names do not match exactly
- the Flow has additional required inputs
- the Flow logic exceeds governor limits
Does the field support namespaced Flows?
Yes. A namespaced Flow can be configured with the namespace prefix in the first segment, for example:
myns__MyFlow;AURA;VF
Related Topics
- Trigger Flow to create Viewer Document - Generate a Viewer document from Salesforce Flow.
- Creating Documents in Salesforce using Apex - Generate documents programmatically from Apex.
- Retrieve Data Using Apex Code with Viewer - Supply external or custom data to templates.
- Automate Email with Document Attachments - Send generated files after automation runs.