How can the map entity be overridden by the data source method, and when can it be used?
MapEntityToDatasource(): It maps the fields from the staging table to the data source used in the entity. Used more for import operations.
Purpose: Whenever we are exporting the data and trying to import it for another legal entity in the Excel sheet, we don’t require the Recid field, so we have used mapentitytodatasource() to map departmentId with recid and showing the field as Department Id.
High Resolution steps
- Create the data entity for Header and line separately.
- Write the mapentitytodatasource method in the entity which has dependency with the header entity.
- Export the data and try to import the data to another legal entity then without recid we can be able to obtain the data .
Detailed Resolution steps:
Step 1: Create the data entity for Header and line separately.

Step 2: Override the mapentityToDatasource() implement the below logic
Code Snippet:

Code:
public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
{
switch (_dataSourceCtx.name())
{
case dataEntityDataSourceStr(MANPOReviewerEntity, MANPOReviewerConfigurationTable):
MANPOReviewerentity poReviewerentity = _entityCtx.getEntityRecord(); //Get Data Entity buffer (Source Entity)
LFC_PODepartmentConfigurationTable departmentConfigurationTable;
str curCompany;
curCompany = curExt();
select departmentConfigurationTable
where departmentConfigurationTable.DepartmentID == poReviewerentity.DepartmentID
&& departmentConfigurationTable.DataAreaId == curCompany;
this.DepartmentIDRefRecId = departmentConfigurationTable.RecId; //Set Target entity field
this.MANPODepartmentConfigurationTable_Department = departmentConfigurationTable.Department;
this.MANPODepartmentConfigurationTable_DepartmentType = departmentConfigurationTable.DepartmentType;
this.MANPODepartmentConfigurationTable_User = departmentConfigurationTable.User;
this.MANPODepartmentConfigurationTable_UserGroup = departmentConfigurationTable.UserGroup;
this.MANPODepartmentConfigurationTable_UserType = departmentConfigurationTable.UserType;
break;
}
super(_entityCtx, _dataSourceCtx);
}
Code Explanation:
The method is designed to populate the fields of a MANPOReviewerEntity with relevant department configuration data based on the department ID and company context. This is likely part of an integration or mapping process in a system dealing with entity configurations.
Step 3: Export the header entity click on export now

Export the line entity by clicking the export now option
Output:
- Import the header data to other legal entity.

After importing the data of header entity in the other legal entity.

- Import the line data to other legal entity without the recid the excel file looks like this.

After importing the data of line entity in the other legal entity.
