Changing document life cycle stages in a script

To change a document life cycle stage in a script, you need to set a value of the LifeCycleStatus type to the Status field of the document.

Script without using PublicAPI

For the script to work correctly, add the following assemblies:
EleWise.ELMA.Documents
EleWise.ELMA.Documents.Docflow

Namespaces:

using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Model.Managers;
 

Script text:

LifeCycleStatus new_status = null;
var statusFilter = InterfaceActivator.Create<Filter>();
statusFilter.Query = "Name LIKE ’Start’";
//search the required document lifec cycle status
new_status = EntityManager<LifeCycleStatus>.Instance.Find(statusFilter, null).FirstOrDefault();
//change the document status
if (new_status != null) context.Dok.Status = new_status;
//save the new document status
context.Dok.Save();
 
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here
Context variables:

context.Document - variable of the Document type

Namespace:

using EleWise.ELMA.API;
 

Script text:

var LCS = PublicAPI.Docflow.Objects.LifeCycleStatus.Create();
LCS = null;
PublicAPI.Docflow.Objects.LifeCycleStatus.Find(FetchOptions.All).ToList().ForEach(lcs =>{
    if (lcs.Name == "Start")
        {
            LCS = lcs;
        }
            });
if (LCS != null) context.Document.Status = LCS; 
context.Document.Save()