To import inventory dimension fields, Microsoft has implemented a map called “InventInventoryDimensionEntityFieldsMapping” which can be used in Data Entity mappings. This map needs to be added to the Data Entity under “Mappings” node and the fields between the map and the Data Entity fields need to be mapped accordingly.
Note: Not the fields of the datasource need to be mapped, but the Data Entity fields itselves. This means that you first need to include the InventDim table as a datasource to your Data Entity and drag the needed inventory dimension fields into your Data Entity fields.
Additionally, the method “mapEntityToDatasource” needs to be implemented with below code. Upon insertion or update, the specified inventory dimensions will be resolved and the InventDim record is returned.
public void mapEntityToDatasource(DataEntityRuntimeContext _entityCtx, DataEntityDatasourceRuntimeContext _dataSourceCtx) { super(_entityCtx, _dataSourceCtx); switch (_dataSourceCtx.name()) { case dataEntityDataSourceStr(SuppItemTableEntity, InventDim): InventDim inventDim = this.InventInventoryDimensionEntityFieldsMapping:resolveInventDim(); _dataSourceCtx.setBuffer(inventDim); _dataSourceCtx.setDatabaseOperation(DataEntityDatabaseOperation:Update); break; } }
Note: If a Data Entity involves more than one InventDim datasource (e.g. a Data Entity for the SuppItemTable table), then the mapping does not work. In this case, custom code needs to be written to map the fields correctly.
Thank you. Very helpful post!
LikeLike