web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to modify main account value in LedgerDimension with X++

(0) ShareShare
ReportReport
Posted on by 334

Hi,

We would like to modify main Account value in LedgerDimension.

I suppose the process should be firstly to find out if the new main account plus the others dimension existed or not. if yes , using the existed dimension , if not, create a new LedgerDimension with new main account and other dimensions.

Is the process correct? and how to do it with x++?

There are too many versions when I google it. Anyone can share a suggestion would be appreciated.

Quatrani 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    Yes you would have to find\create the new ledgerDimension. You can refer below code -

    Container  account;

    RefRecId   ledgerDimension;

    account = ["1000", "1000",3,"LineOfBusiness","D", "Location","NA","Department", "IT];

    ledgerDimension = AxdDimensionUtil::getLedgerAccountId(account);

    container account has main account and available dimensions, you can insert values in container through code as well.

  • JCHI Profile Picture
    334 on at

    Hi Ajit:

    Thanks for the reply.

    I've tried your way.

    Here is what I did.

    1. get the ledgerDimension value then parsing it to a container

    2. replace the Main account , which would be the first and second element

    3. use AxdDimensionUtil::getLedgerAccountId(container) to get a new value

    but It seems the new ledgerDimension value would generate some errors during posting.

    Is this the right way how I did it? and there are many dimension-related class (i.g : DimensionStorage , DimensionDefaultingService, DimensionDefaultingEngine) Can I use these classes to replace value directly instead of parsing it? thanks

    Quatrani

  • Suggested answer
    Ajit Profile Picture
    8,755 on at

    There are many ways to do that, yes we can use those classes as well. FYI,I just tried getLedgerAccountId for creating the invoice journal and posted without an issue. Make sure your account structure is appropriate.

  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi Quatrani,

    What is the purpose? If you change the values, also posted ledger transactions (accounting entries) would be impacted. It is not allowed to change posted transactions in a production environment.

  • Ajit Profile Picture
    8,755 on at

    I don't think Quatrani trying to update the posted transactions.

  • JCHI Profile Picture
    334 on at

    Hi, Ajit, Andre:

    Thank you both for the reply.

    That is correct, I'm not trying to update posted transaction.

    In fact, it is a customization in Expense Report.

    We have a custom field in TrvExpTrans and it it editable before posted.

    This field (payee/vendor) has a main account setting.

    When it is modified. the credit account should be changed alone with it.  

    The idea now is to change the field LedgerDimension in subLedgerJournalAccountEntry.

    Replacing main account maybe other dimension value, too

    I will try Ajit's way to replace main account to see if it can work.

    Thanks!

    Quatrani

  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Thanks for clarification. Indeed changing the LedgerDimension is a far more safe approach.

    You can also have a look at purchase orders where it is possible to specify a main account on the lines. If filled, it will use that value, otherwise it will use inventory posting settings.

  • JCHI Profile Picture
    334 on at

    Hi, André :

    Thanks for the reply.

    You have mentioned we can enter main account in PO line.

    Can you describe it more specifically?

    BTW, I'm having some trouble to find the corresponding subLedgerJournalAccountEntry from TrvExpLines , Do you have any advice?

    Thanks

    Quatrani

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans