The Alterations module exposes a REST API for managing alteration plans. For example, to submit a plan that modifies a variable, migrates the workflow instance to a new version and to schedule an activity, use the following request:
Instead of submitting alteration plans for asynchronous execution, you can apply alterations immediately using the IAlterationRunner service. For example:
When an alteration plan is executed immediately, the alterations are applied synchronously and the results are returned. You will have to manually schedule affected workflow instances to resume execution. Use the IAlteredWorkflowDispatcher:
var dispatcher = serviceProvider.GetRequiredService<IAlteredWorkflowDispatcher>();
await dispatcher.DispatchAsync(results, cancellationToken);
This will tell the workflow engine to pickup the altered workflow instances and execute them.
Extensibility
Elsa Workflows supports custom alteration types, allowing developers to define their own types and utilise them as alterations.
To define a custom alteration type, implement the IAlteration interface.
publicinterfaceIAlteration{}
Next, implement an alteration handler that handles the alteration type.