Übergang erzwingen

Syntax

	forceTransition($processInstance, $targetTask)

Beschreibung

Erzwingt den Übergang einer Prozessinstanz zu einer bestimmten Aufgabenbeschreibung. Diese Methode ermöglicht eine direkte Manipulation des Workflow-Zustandes unter Umgehung der normalen Ablaufsteuerung. Sie sollte mit Bedacht verwendet werden.

Parameter

Name des Prozesses Typ Typ Beschreibung Obligatorisch Standard
processInstance ProzessAusführung Die Prozessinstanz, deren Zustand geändert werden soll. Ja -
targetTask Aufgabenbeschreibung Die Aufgabenbeschreibung, zu der die Prozessinstanz übergehen soll. Ja -

Rückgabewert

Typ: Boolean

Gibt true zurück, wenn der erzwungene Übergang erfolgreich war. Gibt false zurück, wenn der Vorgang fehlgeschlagen ist, z. B. aufgrund ungültiger Argumente oder wenn keine aktiven Token in der Prozessinstanz vorhanden sind.

Beispiele

	//lets say we have a process with 4 Tasks: Submitted, InProgress, Review, Closed
//The normal flow would be:
// Submitted -> InProgress -> Review -> Closed
//But sometimes we need to skip steps and force a processInstance directly to Closed
//This example shows how to move a process from Submitted directly to Closed,
//bypassing both InProgress and Review tasks.
//Here's how we can do this: 

// First create a process instance with a specific name
processInstance = createProcessInstance($startEvent, "Process-001");

// Find the Closed task in our workflow definition
closedTask = all(`tl.bpe.bpml:Participant`)
    // Find the matching participant (workflow)
    .filter(p -> $p.get(`tl.bpe.bpml:Participant#name`) == $processName)
    // Get the single matching participant
    .singleElement()
    // Get its process
    .get(`tl.bpe.bpml:Participant#process`)
    // Get all nodes
    .get(`tl.bpe.bpml:Process#nodes`)
    // Filter out the Closed task
    .filter(n -> $n.get(`tl.bpe.bpml:Node#name`) == "Closed")
    .singleElement();

// Force the process to move directly to the Closed task, skipping InProgress and Review
forceTransition($processInstance, $closedTask)