This article provides answers to the frequently asked questions on ELMA API.

The scripts, specified below, are relevant for ELMA 3.12.1 and lower.

1. How to learn ID or UID of an object?

You can find the UID of an object in Web Application. In table display settings, add this column to the displayed fields.

To find the ID of an object, open the required object in Web Application. The last number in the browser URL bar is the ID.

These IDs can be used to load objects with the methods Load, LoadOrNull, LoadOrCreate.

2. How to work with CommentActionModel, CommentWithDocumentsActionModel and other similar classes?

First, you need to create an instance of this class, fill its properties and then pass its instance to a method.


using EleWise.ELMA.Common.Models;
using EleWise.ELMA.Model.Services;

Script text:

//Create CommentActionModel instance
var model = InterfaceActivator.Create<ICommentActionModel>();
//Create a comment
var comment = PublicAPI.Portal.Objects.Common.Comment.Create();
comment.Text = "Comment";
comment.CreationAuthor = PublicAPI.Portal.Security.User.GetCurrentUser();
comment.CreationDate = DateTime.Now;
//Create an attachment
var attach = PublicAPI.Portal.Objects.Common.Attachment.Create();
attach.CreationAuthor = PublicAPI.Portal.Security.User.GetCurrentUser();
attach.CreationDate = DateTime.Now;
attach.File = context.File;
model.Comment = comment;
//Load a project task
var projectTask = PublicAPI.Projects.ProjectTask.LoadOrNull(24);
//Call CompleteTask method and pass CommentActionModel instance to it
PublicAPI.Projects.ProjectTask.CompleteTask(projectTask, model, false);

3. How to create object instances using ELMA API?

var deal = PublicAPI.CRM.Sale.Create(); 
// deal – is a new deal 
// to create it, fill in its required properties (they might be different for other objects)

In the same way, you can create any other ELMA objects.

For example, documents:

//Create a new instance of the File object 
var documentVersionStatus = PublicAPI.Enums.Documents.DocumentVersionStatus; 
//Attach a version file 
var binaryFile = context.VersionFile; 
var file = PublicAPI.Docflow.Types.File.Create(); 
//Fill in the document’s required attributes
file.CreationAuthor = PublicAPI.Portal.Security.User.GetCurrentUser(); 
file.CreationDate = DateTime.Now; 
PublicAPI.Docflow.DocumentVersion.AddDocumentVersion(file, binaryFile, documentVersionStatus.Current); 

4. How to work with enumerations using ELMA API?

In ELMA API tree, all the enumerations are compiled in the Enums branch and divided into modules.

Document statuses are an example of enumerations in ELMA:

//Define new DocumentVersionStatus enumeration
var versionStatus = PublicAPI.Enums.Documents.DocumentVersionStatus; 
//Create a document 
var document = PublicAPI.Docflow.Types.File.Create(); 
//Call PublicAPI method to add new document version and specify its status using our enumeration
//PublicAPI.Docflow.DocumentVersion.AddDocumentVersion(document, context.File, versionStatus.InArchive); 
document.CreationDate = DateTime.Now; 
document.CreationAuthor = PublicAPI.Portal.Security.User.GetCurrentUser();
//Save the document