logo

Creating a decision in a script

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

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 variable:

context.Document - variable of the Document type

Namespace:

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

Script without PublicAPI

Context variable context.Document1, which contains the document.

For the script to work correctly, add assemblies:

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

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,
new_res.Save();
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​