Hello Gunjan,
Thank you for your suggestion. I think it works for me.
However, I have a problem with allowing the new entity to download via excel. I am trying to put it in the "open in excel" list but with no result..

I used the code below (the source of the code is InventJournalMovement form) and put it in the InventJournalBOM form extension.
Interestingly, the entity appears when I create it with the wizard and select the InventJournalTable data source.

However, in order for this entity to work properly, I need to use the InventJournalTrans datasource - unfortunately with this datasource, the downloadable menuitem does not appear.. (It doesn't matter if I create a new one with wizard or duplicate e.g. InventInventoryMovementJournalEntryEntityV2)
What is the reason for this? I cannot find a solution to this problem.
public const str CustomExportLinesToExcelOptionId = 'LinesCustom';
public void customizeMenuOptions(OfficeMenuOptions _menuOptions)
{
TableName BOMEntry = tableStr(FmTestEntity);
List exportOptions = _menuOptions.customMenuItems();
var exportOptionBOM = OfficeGeneratedExportMenuItem::construct(BOMEntry, CustomExportLinesToExcelOptionId);
exportOptionBOM.setDisplayNameWithDataEntity();
exportOptions.addEnd(exportOptionBOM);
}
public ExportToExcelDataEntityContext getDataEntityContext(OfficeGeneratedExportMenuItem _menuItem)
{
ExportToExcelDataEntityContext context = null;
TableName entityName;
FieldName filterField;
IdentifierName fieldGroupName;
entityName = tableStr(FmTestEntity);
fieldGroupName = tableFieldGroupStr(FmTestEntity, AutoReport);
filterField = fieldStr(FmTestEntity, JournalNumber);
if (entityName && fieldGroupName && filterField)
{
context = ExportToExcelDataEntityContext::construct(entityName, fieldGroupName);
ExportToExcelDataEntityInfo entity = context.findEntityByName(entityName);
if (entity)
{
ExportToExcelFilterTreeBuilder filterBuilder = new ExportToExcelFilterTreeBuilder(entityName);
var filter = filterBuilder.and(
filterBuilder.companyFilter(),
filterBuilder.areEqual(filterField, InventJournalTable.JournalId));
entity.filter(filter);
}
}
return context;
}