Interrupting a process in a script

This example shows the functions for interrupting a process instance (the current process instance cannot be interrupted). The code interrupts the process without checking if the user running the script has special permissions. 

Script with PublicAPI

Note
Documentation on PublicAPI is available here
Attention
The script below is relevant for ELMA version 3.8 to 3.12.1 inclusive.
PublicAPI.Services.Security.RunWithElevatedPrivilegies(() => PublicAPI.Processes.WorkflowInstance.TerminateProcess(context.WorkflowInstance, "Reason"));

Script without PublicAPI

Namespaces:

using EleWise.ELMA.Security;
using EleWise.ELMA.Services;
using EleWise.ELMA.Workflow.Managers;

Script text:

Locator.GetServiceNotNull<SecurityService>().RunWithElevatedPrivilegies(() => WorkflowInstanceManager.Instance.Terminate(context.WorkflowInstance, "Reason"));