ELMA API – a tool for developing scripts in ELMA


Before you start working with scripts, read the guidelines for C# coding.

ELMA API is a set of system methods compiled in an understandable hierarchical structure. ELMA API is intended for developing scripts. You can learn more about developing scripts in this article.

There is a Help for ELMA API with different examples.

ELMA API structure

To work with ELMA API, you need to add the EleWise.ELMA.API namespace.

To start using it, type PublicAPI in the script module of ELMA Designer.

You will see the following:


PublicAPI is the root class for accessing API tree. With IntelliSense, you can see all the nested tree items and find the ones you need.

All API items are divided into units according to ELMA modules:

  • CRM;
  • Docflow (document management);
  • Enums (enumerations);
  • KPI;
  • Objects;
  • Portal (includes objects from Messages, Tasks, and Calendar modules);
  • Processes;
  • Projects;
  • Services

Examples of using ELMA API

The main purpose of ELMA API is to make it easier to create scripts in ELMA by reducing the amount of code required to solve routine tasks.

Consider an example of a script for registering a document.

Script without PublicAPI

//identify entity type based on the document type.
//Instead of "DocType", enter the class name of your document. Note, that the structure uses its interface
var docType =  new ReferenceOnEntityType { TypeUid = InterfaceActivator.UID<IDokType>(false) };
//find a registration variant
var reg_variant = RegistrationVariantManager.Instance
    .Find(new InstanceOf<IRegistrationVariantFilter>(){New =
        //specify the 'Incoming' document flow type
        Docflow = DocumentFlowType.Incoming,
        //specify the document type
        DocumentType = docType,
        //specify a UID for DepositoryGroup. Getting the UID value is described below
        DepositoryGroupUid = new Guid("64AEC71A-D9F3-488E-8E4F-1AD47E31D373"),
        //specify the registration variant name
        Query = "Name = ’Variant1’"
        }}.New, new FetchOptions(0, 1))
//if the registration variant is not found, exit the script
if (reg_variant == null) {
        Console.Write("Variant not found");
//find a category
var depository = (IDepository)DepositoryGroupManager.Instance.GetByGroupUid(reg_variant.DepositoryGroupUid, true)
//if the category is not found, exit the script
if (depository == null)
        Console.Write("Depository not found");
//search record card type in the published records classification scheme
var filter = InterfaceActivator.Create<INomenclatureCacheFilter>();
filter.Depository = depository;
filter.DocumentType = docType;
filter.Flow = reg_variant.Docflow;
filter.RegistrationPlace = reg_variant.RegistrationPlace;         
//if the record card type is not found in the published records classification scheme, exit the script
var cacheItem = NomenclatureCacheManager.Instance.Find(filter, FetchOptions.All).FirstOrDefault();
if (cacheItem == null)
        Console.Write("Cache item not found");
//create a record card of the found type
var rkk = (IRegistrationCard)InterfaceActivator.Create(cacheItem.RegistrationCard.EntityType);
//write the registered document in it
rkk.Document = context.Dok;
//specify the category, in which the document is registered
rkk.Depository = depository;
//specify the document flow, in which the document is registered ('Incoming' in this case)
rkk.Flow = reg_variant.Docflow;
//specify a registration office
rkk.RegistrationPlace = reg_variant.RegistrationPlace;
//and specify the type of the registered document in the record card:
rkk.DocumentType = docType;        
//Registration. Registration number is generated in it
RegistrationCardManager.Instance.Register(rkk, false, null);

Script with PublicAPI

Documentation on PublicAPI is available here
The script below is relevant for ELMA up to 3.12.1 inclusive.
var doc = PublicAPI.Docflow.Types.File.Create();
var regVar = PublicAPI.Docflow.Document.LoadRegVariant(2);
PublicAPI.Docflow.Document.Register(doc, regVar);

Evidently, the difference is significant. This code is much shorter and easier to understand.

See also:

Frequently asked questions about PublicAPI