Calculating values of object properties
In ELMA you can automatically calculate values of object properties using C# scripts.
Object properties can be a context variable of a business process, properties of ELMA objects and attributes of document types/project types.
To create a script for calculating a property value, in ELMA Designer go to the settings of an object property and open the Advanced tab:
In Value calculation type field choose C# script:
For example, in ELMA, there is a Contact object. It has Last Name, First Name, Middle Name properties:
Let’s add a new Full Name property and create a script to calculate the value of this property automatically:
The script code will be the following:
(!string.IsNullOrEmpty(Firstname) && !string.IsNullOrEmpty(Middlename) && !string.IsNullOrEmpty(Surname)) ? string.Format("{0}. {1}. {2}", Firstname.Substring(0,1), Middlename.Substring(0,1), Surname) : " "
In this script, you can only use the property values of the given object. You can also call the object methods.
For example, the User object has a method that returns the full name. To call the method, use the following code:
this.GetFullName()// A method that returns the full name
Now we need to publish the object and restart the ELMA server. Once the new Contact is created in the web application, ELMA will automatically calculate the value of the Initials property: