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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Validate ledger dimension against account structure through x++

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    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
    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
    Kumar Gaurav @ MS Profile Picture
    on at
    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
    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

Responsible AI policies

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

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Rahul Shah Profile Picture

Rahul Shah 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans