During data migration, you may find it necessary to overwrite system fields like 'createdBy' or 'createdDateTime'. In this case, my client has a custom table that stores user comments and relies on these two fields to give context to who and when the comment was created.
1. Create two custom fields on the data entity
- CreatedByMigrated
- CreatedDateTimeMigrated
3. Override (or extend) the insertEntityDatasource() method of your entity
public boolean insertEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
boolean ret;
ARWSpecSheetComments comments;
if(_dataSourceCtx.name() == dataEntityDataSourceStr(ARWSpecSheetCommentsEntity, ARWSpecSheetComments))
comments = _dataSourceCtx.getBuffer() as ARWSpecSheetComments;
}
ret = super(_entityCtx, _dataSourceCtx);
return ret;
3. When importing your entity in data management, make sure the 'createdByMigrated' fields are set in the source to staging mapping, and you will also need to uncheck 'Validate Field' in the target mapping.