/ Search

Search Epistola

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

DocsIntegrationsTourBlogPage
↑↓↵esc

Work in progress — The Learn section is being expanded; alpha, beta, and preview capabilities are labelled where relevant.
← Back to Learn

Handle results and errors

Wait for the PDF, send successful documents to review, and let users correct the case and generate again when it fails.

integrationoperations

Handle generation results

After Valtimo starts document generation, the case should wait until Epistola has finished the PDF.

What a generation leaves behind

The workflow keeps the outcome in a process variable you choose. When Epistola accepts the request, that variable holds a request id and the status PENDING. While Epistola works on it, the status can be IN_PROGRESS. When it ends, the same variable holds one of three statuses:

  • COMPLETED, with the document id;
  • FAILED, with an error message: Epistola accepted the job, but the document did not render;
  • CANCELLED, when the job was cancelled.

A request that Epistola refuses straight away never reaches this variable. Think of a template that is not in the release, or a key without access. The step then fails. If the step is marked Asynchronous before, that becomes an incident that says what is missing. You fix the cause and retry the incident.

  1. Start document generation.
  2. Wait for the completion message from Epistola.
  3. If generation succeeded, download the PDF.
  4. If it did not, show the error and route to a task where someone corrects the case, or to manual review.
  5. Store or send the document only after a successful download.

Two things to watch here:

  • The wait is what wakes the process; the result lands either way. The result wakes the branch that waits for it. While the case is still running, the result also lands in the result variable, whether or not a branch waits. A case that has moved on can still read the outcome or ask for the status later, but nothing resumes it by itself. Once the case has ended, there is nothing left to write to. Keep the wait directly after the generation step, with no asynchronous boundary in between. That way, the result reaches the branch that is waiting for it.
  • Downloading is not the same as filing. The download step makes the document available to the process, by default as a short-lived temporary resource. Getting it into the case’s document store is a separate step afterwards. That step has to happen while the download is still around.

If a case must not wait forever, wait with a receive task that has an interrupting boundary timer. Never wait with an event-based gateway: the result cannot reach it.

Correcting a failed generation

A failed attempt is rarely the end of the case. The cause is almost always in the case: a value is missing or has the wrong form. So the fix belongs in the case too:

  • The failure route leads to a user task with a normal case form.
  • The form shows the error message and the case fields the document uses.
  • The user corrects the case and completes the task.
  • The process loops back to the same generate step. It runs the mapping again, on the corrected case, and Epistola generates a new document.

The failed attempt stays in the history. Because the case itself is corrected, later documents get the correction too.

The error message on that task is the technical reason generation failed. It is useful to the person who can correct the data. It is not diagnostic text for the case worker.

Plugin 1.0 removed the old retry form. It changed the document instead of the case, so the next document failed in the same way.

What users should see

Users should not see technical job details. Show whether the document is waiting, ready, failed, or needs correction.

While no document exists, there is nothing to show. The document component then says so in plain language, instead of showing an empty viewer. To that component, a failed generation looks the same as one that is still running. That is another reason to route the failure explicitly, instead of letting the task sit and wait.

Developer note

The Valtimo plugin stores the technical result state for the workflow. Modelers usually only need the success path and the correction path.

If a case does end up parked on a wait, an administrator can reconcile it. The Pending jobs tab on the Epistola admin page in Valtimo offers this.

Epistola keeps a generated document for a limited period: three months by default. Treat that copy as something to hand over, not as the archive.

In short

  • Keep the wait for Epistola’s completion message directly after the generation step, then route on the outcome.
  • Downloading is not filing: store the document in the case only after a successful download, while the download is still around.
  • Route a failed generation to a task where someone corrects the case, so later documents get the correction too.

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 →