Signing a document version in a script

Consider a script which allows signing the current document version.

Script with PublicAPI

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

Context variables:

context.Director - variable of the User type
context.Document - variable of the Document type


using EleWise.ELMA.API;
Script text
foreach (var vers in PublicAPI.Docflow.DocumentVersion.Filter().Document(context.Document).Status(PublicAPI.Enums.Documents.DocumentVersionStatus.Current).Find())
    var user = PublicAPI.Docflow.Objects.DocumentAssignUser.Create();
    user.User = context.Director;
    user.DocumentVersion = vers;

Script without PublicAPI

Context variables are used in the script:
context.Document - variable of the Contract (document type) type
context.Director - variable of the User type

For the script to work, add the following assemblies:



using EleWise.ELMA.Documents;
using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Extensions;
using EleWise.ELMA.Model.Entities;
using EleWise.ELMA.Model.Services;
using FluentNHibernate.Conventions;
Script text:
var vers = DocumentVersionManager.Instance.Get(context.Document.Id).ToList(); //get all the document versions
foreach (var i in vers)
if (i.Status == DocumentVersionStatus.Current) //search for the current version
    var v_sign = DocumentVersionExtManager.Instance.Load(i.Id);
    var user = DocumentAssignUserManager.Instance.Create();
    user.User = context.Director;//specify the user who signs the document
    user.DocumentVersion = i;
    v_sign.SignedUsers.Add(user); //add the users who signed the document to the list