2 min read

In Microsoft Dynamics AX 2012 the Default account setup Lookup form is listing Main Accounts from all Company Accounts rather than just active Company Accounts

We came across an issue recently where the “Default account setup” Lookup form is listing Main Accounts from all Company Accounts. We are using Microsoft Dynamics AX 2012 CU-2. The selection in some queries brought unexpected results. For example: Under Accounts payable > Setup > Vendors > Vendor groups. Then select one Vendor and click “Default account setup”. The look up will then list the Main Accounts from all Company Accounts instead of only the current active Company Account.

The results are derived as a result of the where clause selection in \Data Dictionary\Tables\VendDefaultAccounts\Methods\notSelectedLedgerAccountList method

We worked around the issue by changing one line of code in the notSelectedLedgerAccountList method from

outer join RecId from dimAttributeValueCombo where
dimAttributeValueCombo.DisplayValue == mainAccount.MainAccountId && 
dimAttributeValueCombo.LedgerDimensionType == LedgerDimensionType::DefaultAccount


outer join RecId from dimAttributeValueCombo where
dimAttributeValueCombo.MainAccount == mainAccount.RecId &&
dimAttributeValueCombo.LedgerDimensionType == LedgerDimensionType::DefaultAccount

For completeness, the full method code and modified line is shown in the highlight below:

public server static List notSelectedLedgerAccountList()
MainAccount                         mainAccount;
DimensionAttributeValue             dimAttributeValue;
DimensionAttributeValueCombination  dimAttributeValueCombo;
VendLedgerAccounts                  vendLedgerAccounts;
List                                notSelectedFieldList    = new List(Types::Container);
recId                               defaultAccountHierarchyId =
recId                               mainAccountDimAttribute =

// Allow all posting types, so long as they are not closed
// Only add the combination if it doesn’t exist or doesn’t exist as a ledger dimension on the
vendLedgerAccounts table
while select MainAccountId, Name, Type from mainAccount order by MainAccountId where
mainAccount.LedgerChartOfAccounts == LedgerChartOfAccounts::current() &&
mainAccount.Type != DimensionLedgerAccountType::Total
outer join RecId from dimAttributeValueCombo where
            //dimAttributeValueCombo.DisplayValue == mainAccount.MainAccountId && //original code
            dimAttributeValueCombo.MainAccount == mainAccount.RecId && //modified Code
dimAttributeValueCombo.LedgerDimensionType == LedgerDimensionType::DefaultAccount
outer join RecId from vendLedgerAccounts where
(vendLedgerAccounts.SummaryLedgerDimension == dimAttributeValueCombo.RecId ||
vendLedgerAccounts.ClearingLedgerDimension == dimAttributeValueCombo.RecId ||
vendLedgerAccounts.PurchasingLedgerDimension == dimAttributeValueCombo.RecId ||
vendLedgerAccounts.PurchasingOffsetLedgerDimension == dimAttributeValueCombo.RecId)
notexists join dimAttributeValue where
dimAttributeValue.DimensionAttribute == mainAccountDimAttribute &&
dimAttributeValue.EntityInstance == mainAccount.RecId &&
(dimAttributeValue.IsSuspended == true ||
dimAttributeValue.IsBlockedForManualEntry == true)
if (!vendLedgerAccounts)
notSelectedFieldList.addEnd([mainAccount.MainAccountId, mainAccount.Name, mainAccount.Type]);
return notSelectedFieldList;

This programming example is for illustration purposes only. Microsoft disclaims all warranties and conditions with regard to use of the programming example for other purposes. Microsoft shall not, at any time, be liable for any special, direct, indirect or consequential damages, whether in an action of contract, negligence or other action arising out of or in connection with the use or performance of the programming example. Nothing herein should be construed as constituting any kind of warranty.