Creating a decision in a script

The scripts provided below are intended for creating a decision on a document.

Script without using PublicAPI

Context variable context.Document1, which contains the document.

For the script to work correctly, add assemblies:


And namespaces:

using EleWise.ELMA.Documents.Managers;
using EleWise.ELMA.Documents.Models;
using EleWise.ELMA.Documents.Models.Tasks;
using EleWise.ELMA.Model.Common;
using EleWise.ELMA.Model.Managers;
using EleWise.ELMA.Tasks.Models;
using EleWise.ELMA.Model.Services;
Script text:
var new_res = InterfaceActivator.Create<Resolution>(); //create a new decision
new_res.Author = context.Author; //specify the decision author, you can use any variable of the User type
new_res.Date = DateTime.Now; //specify the decision date
new_res.Document = context.Document; //bind the decision with the document
new_res.Status = ResolutionStatus.CreateTasks; //set the required decision status,
var result = InterfaceActivator.Create<ResolutionResult>(); //create the decision result
result.CreationDate = DateTime.Now; //set the result date
result.Resolution = new_res; //bind the result with the decision
result.Text = "Decision text"; //decision content
result.User = context.Author; //a decision may have several results, therefore, you need to specify its author
result.Save(); //save the result
new_res.Results.Add(result); //add it to the list of decision results
new_res.Save(); //save the decision​

Creating a similar script with PublicAPI
Documentation on PublicAPI is available here
Context variable:

context.Document - variable of the Document type


using EleWise.ELMA.API;
Script text:
var new_res = PublicAPI.Docflow.Tasks.CreateResolution(context.Document); //create a decision and link it with the document
var result = PublicAPI.Docflow.Tasks.CreateResult(new_res,"Decision text"); //create a decision result
new_res.Results.Add(result); //add it to the list of decision results
new_res.Save(); //save the decision