Hi Joe,
The postLoad method can be used if you have also the original fields in your staging table. Then you can use something like this:
/// <summary> /// Map data fields to virtual fields /// </summary> public void postLoad() { this.TableName = tableId2Name(this.Table); this.FieldName = fieldId2Name(this.Table, this.Field); this.ExtendedTypeName = extendedTypeId2name(this.ExtendedTypeId); }
When you need to map the virtual fields to the target datasource, you can use the method mapEntityToDataSource(). An example:
public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx) { super(_entityCtx, _dataSourceCtx); if (_entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Insert || _entityCtx.getDatabaseOperation() == DataEntityDatabaseOperation::Update) { if (_dataSourceCtx.name() == dataentitydatasourcestr(MyEntity, MyTable)) { MyTable myTable = _dataSourceCtx.getBuffer(); myTable.Table = tableName2Id(this.TableName); myTable.Field = fieldName2Id(myTable.Table, this.FieldName); } } }
You can also use the metadata search for examples of entities in D365 which are also using these methods.