Adding users to the list of document approvers with a script

Let's say the context.Doc variable of a process stores a document, which already has an active approval sheet and the context.Users variable (User type, List link type) stores the list of users to add to the list of the document approvers and assign approval tasks to. You can do it using the following script.

Script with PublicAPI

Note
Documentation on PublicAPI is available here
Attention
The script below is relevant for ELMA up to 3.12.1 inclusive.

Context variables:

context.Document - variable of the Document type
context.User - variable of the User type, List link type

Namespace:

using EleWise.ELMA.API;

Script text:

var group = PublicAPI.Docflow.Tasks.GetApprovementGroupsByDocument(context.Document).LastOrDefault();//get the last approval
PublicAPI.Docflow.Tasks.AddExecutors(group, context.User);

Script without using PublicAPI

For the script to work, add the assemblies:

EleWise.ELMA.Documents
EleWise.ELMA.Documents.Docflow

Namespaces:

using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.Security.Models;
Script text:
var group = ApprovementTaskGroupManager.Instance.GetGroupsByDocument(context.Doc).LastOrDefault();//get the last approval
ApprovementTaskGroupManager.Instance.AddExecuters(group, context.Users.Select(u => new Pair<IUser, IUser>(u, null)));