Link between the contractor and company objects

This article describes how you can access the attributes of the Company object if a process uses a Contractor object.

Contractor and Company are linked by ID. An example of a script for getting the KPP is below.
 
Script without using PublicAPI.

The script includes the following context variables:

context.Client - variable of the Contractor type
context.KPP - variable of the String type

For the script to work, add the following assembly:

Elewise.ELMA.CRM

Namespaces:

 
using EleWise.ELMA.Model.Managers;
using NHibernate.Event.Default;
using EleWise.ELMA.CRM.Models;
using EleWise.ELMA.CRM.Managers;
Script:
var mng=EntityManager<ContractorLegal>.Instance;
var cl=mng.LoadOrNull(context.Client.Id);//load company by ID
if (cl != null)
{
        context.KPP=cl.KPP;
}
 
Creating a similar script with PublicAPI
Documentation on PublicAPI is available here

Context variables:

context.Contractor - variable of the Contractor type
context.KPP - variable of the String type

Namespace:

 
using EleWise.ELMA.API;

Script:

 
var mng = PublicAPI.CRM.Contractor.ContractorLegal.LoadOrNull(context.Contractor);
if (mng != null){
            context.KPP = mng.KPP;
};