ELMA API FAQ

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

1. How to learn ID of an object?

You can do that in ELMA web application. Simply open the object page and look at its URL address. The last number in the URL bar is the ID of selected object. The picture below shows how you can find a contractor’s ID:

2. How to learn GUID of an object?

GUID is an object property and it can be displayed in ELMA web application.

First of all, you need to open the table display settings of an object. The picture below shows how to so:

In the table display settings, move UID property to the Selected Fields:

 

After that, GUIDs will be displayed in the table along with other selected properties:

3. 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.

For example:

//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;
comment.Save();
//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;
attach.Save();
model.Attachments.Add(attach);
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);

4. 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); 
file.Save();

5. 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 
document.Save();