Hi everyone,
I’ve created a custom data entity with the header data source as LedgerJournalTable, and added it as a template so that it can be opened in Excel using the Office Add-in.
According to the Microsoft Learn documentation, when the header data source of the entity matches the main data source of the form, the entity should automatically appear in the Office Integration section of the form.
However, in my case, it’s not showing up under the Office integration options.
Has anyone faced a similar issue or know what could be missing in my setup?
using Microsoft.Dynamics.Platform.Integration.Office;
/// <summary>
/// The <c>ExpenseJournalExcelTemplate</c> is the supporting class for the expense journal excel template.
/// </summary>
public class ExpenseJournalExcelTemplateCopy extends DocuTemplateRegistrationBase implements LedgerIJournalExcelTemplate
{
private const DocuTemplateName ExcelTemplateName = resourceStr(ProjectExpenseJournalCopy);
private const DataEntityName LineEntityName = tableStr(ExpenseJournalLineEntityCopy);
private const FieldName LineEntityJournalNum = fieldStr(ExpenseJournalLineEntityCopy, JournalBatchNumber);
private const FieldName LineEntityDataAreaId = fieldStr(ExpenseJournalLineEntityCopy, dataAreaId);
private const DataEntityName HeaderEntityName = tableStr(ExpenseJournalHeaderEntityCopy);
private const FieldName HeaderEntityJournalNum = fieldStr(ExpenseJournalHeaderEntityCopy, JournalBatchNumber);
private const FieldName HeaderEntityDataAreaId = fieldStr(ExpenseJournalHeaderEntityCopy, dataAreaId);
public boolean isJournalTypeSupported(LedgerJournalType _ledgerJournalType)
{
return _ledgerJournalType == LedgerJournalType::Cost;
}
public void applyCustomTrimming(Excel.IWorkbookManager _templateManager, Excel.WorkbookSettingsManager _settingsManager, LedgerJournalTable _ledgerJournalTable)
{
}
public DocuTemplateName documentTemplateName()
{
return ExcelTemplateName;
}
public Set supportedAccountTypes()
{
Set accountTypeSet = new Set(Types::Integer);
accountTypeSet.add(LedgerJournalACType::Project);
return accountTypeSet;
}
public Set supportedOffsetAccountTypes()
{
Set offsetAccountTypeSet = new Set(Types::Integer);
offsetAccountTypeSet.add(LedgerJournalACType::Ledger);
offsetAccountTypeSet.add(LedgerJournalACType::Cust);
offsetAccountTypeSet.add(LedgerJournalACType::Vend);
offsetAccountTypeSet.add(LedgerJournalACType::Bank);
return offsetAccountTypeSet;
}
public boolean validateJournalForTemplate(LedgerJournalTable _ledgerJournalTable)
{
return LedgerJournalExcelTemplate::validateJournalForTemplate(_ledgerJournalTable, this);
}
public void registerTemplates()
{
this.addTemplate(
OfficeAppApplicationType::Excel,
ExcelTemplateName,
ExcelTemplateName,
literalStr("Journal lines copy for project"),
literalStr("Journal lines copy for project"),
NoYes::No,
NoYes::No);
}
public DataEntityName headerEntityName()
{
return HeaderEntityName;
}
public DataEntityName lineEntityName()
{
return LineEntityName;
}
public FieldName headerJournalBatchNumberFieldName()
{
return HeaderEntityJournalNum;
}
public FieldName headerDataAreaFieldName()
{
return HeaderEntityDataAreaId;
}
public FieldName lineJournalBatchNumberFieldName()
{
return LineEntityJournalNum;
}
public FieldName lineDataAreaFieldName()
{
return LineEntityDataAreaId;
}
public Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode appendHeaderEntityFilters(Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode _headerFilter, ExportToExcelFilterTreeBuilder _headerFilterBuilder)
{
return _headerFilter;
}
public Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode appendLineEntityFilters(Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode _lineFilter, ExportToExcelFilterTreeBuilder _lineFilterBuilder)
{
Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode ledgerVend = _lineFilterBuilder.or(
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntityCopy, OffsetAccountType), LedgerJournalACType::Ledger),
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntityCopy, OffsetAccountType), LedgerJournalACType::Vend));
Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode custBank = _lineFilterBuilder.or(
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntityCopy, OffsetAccountType), LedgerJournalACType::Cust),
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntityCopy, OffsetAccountType), LedgerJournalACType::Bank));
Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode offsetFilters = _lineFilterBuilder.or(ledgerVend,custBank);
Microsoft.Dynamics.Platform.Integration.Office.FilterCollectionNode ledgerFilter = _lineFilterBuilder.and(
_lineFilterBuilder.areEqual(fieldStr(ExpenseJournalLineEntityCopy, AccountType), LedgerJournalACType::Project),
offsetFilters);
return _lineFilterBuilder.and(_lineFilter, ledgerFilter);
}
}