SPA
One of the main CRM features is tracing, storage and convenient display of communications. Communications are not always connected with sales. Communications can include internal processes, tech support requests processing, purchase orders and etc. In such cases, information must be stored and processed not inside leads/deals, but separately. Additionally, CRM often stores significant amount of information, associated with sales, but not lead/deals. To satisfy this requirement, Smart processes were introduced starting from CRM version 20.700.0.
What is a Smart Process Automation (SPA)?
Each smart process - is a new entity within CRM with newly created section with its interface, set of features, fields, items and etc.
In other words, SPA can be called a "Custom CRM entity", "Universal CRM entity" or "Dynamic CRM entity type".
Smart Processes are in-built to new CRM API.
Data
Conceptually SPAs are similar to iblocks (Lists). Each SPA is an iblock type.
In terms of data handling, SPAs are similar to RPA
.
Mechanism of custom field storage is the same as in RPA
and highloadblock
.
- SPA table and EntityObject;
- SPA pipeline table
- Rules for status table ID generation of (see. SPA stage table);
- SPA elemens' abstract DAO and EntityObject for them;
- Full-text search abstract DAO for SPA items;
- Contact binding table.
Note: Table structure will include option to indicate multiple responsible users for SPA items. However, this feature is pending release at the moment.
Items storage specifics
Each SPA has its own set of elements. In this regard, hierarchy is similar to iblocks, where process is an iblock type with iblock elements. For SPA, custom fields from kernel are used instead of iblock properties.
Majority of code, responsible for element and custom property storage is concentrated in the folder modules/main/lib/userfield/internal
This article details general process of dynamic creation of tables and columns.
System fields
All tables of SPA items/elements have a set of system fields, see more in \Bitrix\Crm\Model\Dynamic\PrototypeItem
.
Portion of SPA item fields can be hidden via the SPA settings, but columns for storing these fields as well as their current values cannot be deleted.
They remain in place, only stopping to be displayed in the UI with some workflow logic associated with these fields is removed as well.
Also, please note that SPA item is always associated to a pipeline and stage. Even if feature is disabled, SPA always has at least one pipeline and a stage.
When such elements are distributed by stages and then the feature is then disabled, item bindings are saved.
Learn more details about system fields here.
Full text index
Each process has dynamically created table for full-text index storage.
Class \Bitrix\Crm\Model\Dynamic\PrototypeItemIndex
.
Tables are located here \Bitrix\Crm\Model\Dynamic\TypeTable::onAfterAdd
.
SPA stages
ENTITY_ID
Stages data are stored in the table b_crm_status
ENTITY_ID
field is generated as
'DYNAMIC_' + {entityTypeId} + '_STAGE_' + {categoryId}
This field value can be retrieved via the following API method \Bitrix\Crm\Service\Factory::getStagesEntityId()
For exmaple, SPA with ID 150 and pipeline 3 the field is as follows:
DYNAMIC_150_STAGE_3
STATUS_ID
Prefix for STATUS_ID
is generated as
'DT' + {entityTypeId} + '_' + {categoryId} + ':'
For example, the field is DT150_3:SUCCESS
for default final stage for SPA with ID 150 in pipeline 3
You can retrieve prefix for SPA via API method \CCrmStatus::getDynamicEntityStatusPrefix()