/ Search

Search Epistola

Find documentation, integration guides, tour steps, blog posts and pages.

DocsIntegrationsTourBlogPage
↑↓↵esc

Wait for Documents

Model the workflow so the case waits for the generated PDF and handles success or failure clearly.

Wait for documents

Generating a document takes a moment. Build the process so the case waits until the PDF is ready.

  1. Start document generation with Generate Document.
  2. Add a message intermediate catch event with the message name EpistolaDocumentGenerated. It needs no listener or script: the plugin connects it.
  3. Add a gateway that checks ${epistolaResult.status == 'COMPLETED'}. Use the name of your result variable.
  4. If the document is completed, route it to download, storage, or review.
  5. If it is not, route it to a task where someone corrects the case. See Preview and correct.

Keep the wait directly after the generate step. Do not put an asynchronous boundary between the two. Otherwise the result can arrive before the wait is ready.

What the result variable holds

When Epistola accepts the request, the result variable holds the request ID and the status PENDING. When the job finishes, the plugin updates the same variable:

  • COMPLETED, with the documentId of the PDF.
  • FAILED, with an errorMessage. Epistola accepted the job, but the document did not render.
  • CANCELLED, when the job was cancelled.

While the job runs, the status can also be IN_PROGRESS.

A request that Epistola refuses straight away does not reach the result variable. It becomes an incident, if the generate step is Asynchronous before.

Without a wait step

A process does not have to wait. The plugin also updates the result variable when no branch waits for it, as long as the process still runs. A later task can then read ${epistolaResult.documentId}. That task must handle the status PENDING, because the document may not be ready yet.

Parallel documents

If a case generates more than one document at the same time, give each generate step its own result variable and its own wait. The plugin wakes exactly the branch that waits for that document.

If one wait receives branches with different result variables, the plugin cannot tell which document it waits for. Use one shared result variable in that case. The BPMN validation tab on the Epistola admin page warns about this.

Timeouts

If a case must continue after a certain time, wait with a receive task instead of a catch event. Give the receive task the message EpistolaDocumentGenerated and an interrupting boundary timer, for example PT30M. The timer route runs if the document does not arrive in time.

Never wait with an event-based gateway. The plugin cannot deliver the result there, so only the timer route ever runs.

Polling

The Check Job Status action asks Epistola for the status of a request. It writes the status, the document ID and the error message to process variables you name. A loop with a timer and this action works, but each waiting case wakes up again and again. Use the catch event when you can.

Troubleshooting

If a case seems stuck, open the Epistola admin page in Valtimo. Click your configuration and open the Pending jobs tab. Click Reconcile on the row: if the job has finished, the process continues.

Reconcile cannot help if the process was moved back to the wait without passing the generate step again. In that case, move the process back to the generate step, so it generates a new document.

More on this topic

Epistola is open source, not free of cost. The organisations that use it fund its development, through Epistola or an Official Partner. We are steward-owned: fair prices, no profit maximisation. How Epistola is funded →