Customised Export to Word, using OfficeITemplateCustomExporter exports wrong dataset

Dear all,
I've an own form, called ANXTMSTransportOrderTable

It is able to export to Excel by itself, having a corresponding excel template.

I need to add an export to word.

For this I followed the microsoft article

https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/office-integration/customize-open-office-menu

and added some word templates to the menu, using following code:

public class ANXTMSTransportOrderTable extends FormRun implements OfficeITemplateCustomExporter
{

// some unimportant code...

void customizeMenuOptions(OfficeMenuOptions _menuOptions)
{
DocuTemplate docTemp = DocuTemplate::findTemplatesForEntity("ANXTMSTransportOrderTableEntity");
while(docTemp)
{
OfficeTemplateExportMenuItem menuItem = OfficeTemplateExportMenuItem::construct(docTemp.TemplateType, docTemp.TemplateID, docTemp.TemplateID);
_menuOptions.customMenuItems().addEnd(menuItem);

next docTemp;
}
}

Map getInitialTemplateFilters(OfficeTemplateExportMenuItem _menuItem)
{
Map initialFilters = new Map(Types::String, Types::Class);
return initialFilters;
}

void updateTemplateSettings(OfficeTemplateExportMenuItem _menuItem, Microsoft.Dynamics.Platform.Integration.Office.SettingsManager _settingsManager)
{
}

It is working well as far as it shows the templates, which are integrated to my AX.

But when I export a word document, it always exports the dataset with the smallest RecId from the table.

Using the "given by AX" Excel Export, it exports the correct dataset, having the focus.

I'm not able to find any documentation about what I'm doing wrong.

I have a grid with the DataSource ANXTMSTransportOrderTable.
My templates are based on the entity ANXTMSTransportOrderTableEntity. It is used in the method to add the right menuitems.

The entity is using a view, which is using a Query, which has only ANXTMSTransportOrderTable as datasource. I assume the excel template ist ussing the same entity.

It seems to be not that wrong, because I receive data from the correct table, but not from the correct dataset.

So for my opinion some connection info is missing, to give the export the information about the actual dataset of the grid.

I use AX 365, updated to PU41.

Does anybody have an idea, what I'd doing wrong?

kind regards and thank You for helping.

Gerhard

Parents Reply Children
No Data
Related
Recommended