Executing a script under a specific user

In 3.0 scrips are run from the name of the user who belongs to the swimlane where the previously executed process activity is located. Starting from 3.0.6 all the scripts by default are run from the name of the user who is responsible for the process instance, but it is also possible to run scripts under the name of a selected user. To select a user, use the RunByUser method.

Example of a script without using PublicAPI.
Required namespaces:
using EleWise.ELMA.Security;
using EleWise.ELMA.Services;

Script text:

var securityService = Locator.GetService<ISecurityService>();
securityService.RunByUser(user, () => {
 //code; 
});

The code in brackets will be executed under the name of the specified user.

Creating a similar script with PublicAPI
Updated information on PublicAPI is available here.
The script given above works for PublicAPI version 3.8 and higher
var user = PublicAPI.Portal.Security.User.GetCurrentUser(); 
PublicAPI.Services.Security.RunByUser(user, () =>
{
    //code;
});