Skip to main content

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
What this field does

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:

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

Valid field values
SendNotification;AURA
UpdateRelatedRecords;AURA;VF;INVOCABLE_ACTION
c__DocumentProcessor;AURA;SYNCHRONOUS
CallExternalAPI;SYNCHRONOUS;REST;FUTURE
myns__BatchProcessor;BATCH_APEX;QUEUEABLE

Invalid examples

Invalid field values
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
Unmanaged and managed examples
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:

QuiddityTypical use
AURAUser-initiated generation from Lightning or Aura pages
VFUser-initiated generation from Visualforce pages
SYNCHRONOUSSynchronous web-service generation
RESTREST API generation
FUTUREFuture method processing
QUEUEABLEQueueable Apex jobs
BATCH_APEXBatch Apex jobs
SCHEDULEDScheduled Apex jobs
INVOCABLE_ACTIONFlow or Process action generation
ANONYMOUSAnonymous Apex testing or debugging

Required Flow inputs

Your Flow must be an Autolaunched Flow and must include these input variables.

VariableTypeAvailable for InputPurpose
newFileIdTextYesThe generated ContentVersion ID
recordIdTextYesThe source business record ID
templateIdTextYesThe template record ID
Input names must match exactly

Use the exact variable names from the source guide:

  • newFileId
  • recordId
  • templateId

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:

  • newFileId
  • recordId
  • templateId

2. Update the template

Open the Viewer template record and set the Post Flow API field.

Example:

Template field value
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.

Post Flow API value
RenameGeneratedFile;AURA;VF;INVOCABLE_ACTION

What the Flow can do:

  • use recordId to get the source record values
  • use templateId to get the template name or category
  • use newFileId to find the generated ContentVersion
  • 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.

Post Flow API value
EmailGeneratedFile;AURA;INVOCABLE_ACTION

What the Flow can do:

  • use newFileId to get the generated file
  • use recordId to get the recipient or related business context
  • use templateId to 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.

Post Flow API value
UpdateOpportunityStage;AURA;VF;INVOCABLE_ACTION

What the Flow can do:

  • use recordId to 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.

Post Flow API value
dms__SyncToExternalDMS;SYNCHRONOUS;REST

What the Flow can do:

  • use newFileId to look up the new file
  • use templateId to 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

Recommended setup
  • 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:

Namespaced Flow example
myns__MyFlow;AURA;VF