logo

Working with custom fields of objects in scripts

You can extend ELMA object model with your own objects/object properties. You can also add your own properties which you create in the ELMA designer to the system objects (learn more about it in ELMA Help).

Let's see how to access custom properties of the system objects. In business process scripts, you can access custom properties through the object class. For example, Contractor is a class for the Contractor object; Product is the class for Products and Services object. But these classes are not available for the objects/documents scripts; you have to use a special interface which extends the system interface. This happens because objects and documents, unlike processes, are assembled when a user starts the system; in this case, only class interfaces are available, though classes are not assembled yet. The general rule is to add ConfigExt to the interface name.

For example, you need to access the custom property Stock number of the Products and Services object from the script module of the Commercial proposal document type.

First, add the Stock number property to the Products and Services object. You can do that in ELMA DesignerObjectsCRMProducts and Services.

Next, create the Commercial proposal document type and add the Goods block with the following properties:

  • Item property of the Products and Services type;
  • Article When a user selects an Item, a script will fill in the value of the Article property.

Finally, add the SpecifyArticle script to the Item property, so that it was executed when the property changes:

public virtual void SpecifyArticle (ICommercialProposal entity, ICommercialProposal_Goods item, EleWise.ELMA.Model.Views.FormViewBuilder<ICommercialProposal_Goods> form)
{
//to access the custom property Article, cast the Item property to the IProductConfigExt interface
item.Article = (item.Item as IProductConfigExt).Article;
}

It works in the same way for any other ELMA objects. For example, if you add the custom property Native name to the Contractor object, then you will be able to access it from the script modules of objects/documents using the following expression: (contractor as IContractorConfigExt).NativeName; where contractor – is a property of Contractor type.