Skip to main content
X++ Development · · 1 min read

Get Customer Account from Journal ID

 Retrieve the customer account from a journal ID using X++ in D365 Finance and Operations. 

A

Ahmad Hassan

Dynamics 365 F&O Consultant

Share
Get Customer Account from Journal ID

This X++ method retrieves the customer account associated with a specified journal ID.
It identifies the customer-type ledger journal transaction and obtains its LedgerDimension.
The dimension combination is then used to find the corresponding customer record, and the customer account number is returned.

X++ Code

public static CustAccount getcustomer(JournalId _JournalId)

{

    LedgerJournalTrans                    _ledgerJournalTrans;

    CustTable                             custTable;

    DimensionAttributeValueCombination    combination;

    select JournalNum,LedgerDimension from _ledgerJournalTrans

            where _ledgerJournalTrans.JournalNum  == _JournalId

               && _ledgerJournalTrans.AccountType == LedgerJournalACType::Cust;

    combination = DimensionAttributeValueCombination::find(_ledgerJournalTrans.LedgerDimension);

    custTable = CustTable::find(combination.DisplayValue);

    return custTable.AccountNum;

}

Process Flow

The method receives a journal ID and selects the related LedgerJournalTrans record where the account type is Cust.

It retrieves the transaction's LedgerDimension and finds the related DimensionAttributeValueCombination record.

The combination's DisplayValue is used to find the corresponding CustTable record.

Finally, the method returns the customer's AccountNum.

2cc17fa8-6275-4fd9-9a4c-eb7e7c7e75c8.png

Figure: Flow of retrieving a customer account from a customer ledger journal transaction.

Found this useful?

Share it with your network

A

Written by

Ahmad Hassan

Microsoft Dynamics 365 Finance & Operation, Technical Consultant

More about me

Related Posts

Comments

Leave a comment