Skip to main content

Notifications

Microsoft Dynamics AX (Archived)
Answered

Validate ledger dimension against account structure through x++

Posted on by

Hi All,

I have a ledger dimension which I want to validate against an account structure in my code, can you please suggest if I can do that and how.

Cheers!

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Validate ledger dimension against account structure through x++

    Hi Kumar,

    Coding can be divided in this way,

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Validate ledger dimension against account structure through x++

    Thank you Dominic,

    I use one transaction with two items and a financial dimension that is different, but I get a bug like this

    Function DimensionDefaultingEngine::insertDimensionSpecifer has been incorrectly called.

    help me

  • Verified answer
    RE: Validate ledger dimension against account structure through x++

    Thanks for the response Dominic,

    I found a way to do it by following code

    DimensionValidation::validateByTree(ledgerDimensionRecId,today(),true)  

    I didn't needed to go into service which I am sure will be required in other complex scenarios

  • Verified answer
    dolee Profile Picture
    dolee 11,279 on at
    RE: Validate ledger dimension against account structure through x++

    Hi,

    Please try this:

    static void ValidateLedgerDimension(Args _args)

    {

       str mainAcctNum = "110130";

       LedgerAccountValidationContract validationContract;

       LedgerAccountContract           accountContract;

       DimensionAttributeValueContract valueContract;

       FinancialDimensionValidationService service;

       List listValueContract = new List(Types::Class);

       // Business Unit

       valueContract = new DimensionAttributeValueContract();

       valueContract.parmName("BusinessUnit");

       valueContract.parmValue("002");

       listValueContract.addEnd(valueContract);

       // Department

       valueContract = new DimensionAttributeValueContract();

       valueContract.parmName("Department");

       valueContract.parmValue("028");

       listValueContract.addEnd(valueContract);

       accountContract = new LedgerAccountContract();

       accountContract.parmMainAccount(mainAcctNum);

       accountContract.parmValues(listValueContract);

       validationContract = new LedgerAccountValidationContract();

       validationContract.parmLedgerAccount(accountContract);

       validationContract.parmValidDate(systemDateGet());

       service = new FinancialDimensionValidationService();

       if (service.validateLedgerAccount(validationContract))

       {

           info("Valid");

       }

       else

       {

           info("Invalid");

       }

    }

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans