Creating a document using a script
Script that creates a document of the Procedure type in a business process.
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 variables:
context.Name - variable of the String type
context.File - variable of the File type
context.Document - variable of the Document type
Namespace:
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.
Namespaces:
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;
doc.Versions.Add(version);
//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);
//Save
doc.Save();
// Match the created document with the context variable of the process
context.Procedure = (Procedure)doc;