16 Jan 2014

Bank account from main account + AX

The following method finds a bank account from the main account attached to it. This is a general approach for relating the main account number to a record storing an account or account+dimensions combination.

Note use of DimensionAttributeValueCombination and MainAccount tables.


BankAccountTable bankAccountFromMainAccount(MainAccountNum mainAccountNum)
{
// Lookup bank account from main account

BankAccountTable bankAccountTable;
DimensionAttributeValueCombination valueCom;
MainAccount mainAccount;

select firstOnly bankAccountTable
join valueCom
where valueCom.RecId == bankAccountTable.LedgerDimension
join mainAccount
where mainAccount.RecId == valueCom.MainAccount
&& mainAccount.MainAccountId == mainAccountNum;

if(!bankAccountTable)
this.throwError(strFmt("Could not find bank account with main account '%1'",mainAccountNum));

return bankAccountTable;
}


No comments:

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...