Creating a document using a script

Script that creates a document of the Procedure type in a business process.

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.Name - variable of the String type
context.File - variable of the File type
context.Document - variable of the Document type


using EleWise.ELMA.API;
Script text:
//New document of the Contract type
context.Document = PublicAPI.Docflow.Types.Contract.Create(context.File, PublicAPI.Docflow.Folder.Load(33), context.Name);

Script without PublicAPI

Context variables:
context.ProcedureFile - variable of the File type
context.ProcedureName - variable of the String type.


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

Script text:

//New document
var doc = InterfaceActivator.Create<Procedure>();         
//Identify the folder
doc.Folder = (Folder)FolderManager.Instance.Load(35);
//Generate a version
var version =  InterfaceActivator.Create<DocumentVersion>();
version.Document = doc;
//Set the version status - Current
version.Status = DocumentVersionStatus.Current;
//Attach the version file
version.File = context.ProcedureFile;
//Specify a name
doc.Name = context.ProcedureName;
//To generate a name by template
//doc.Name = DocumentManager.Instance.GenerateName(doc, null, true); 
// Match the created document with the context variable of the process
context.Procedure = (Procedure)doc;