Monday, July 1, 2024

Generate Ledger dimension for MainAccount in D365F&O X++

     public static void main(Args _args)

    {

        MainAccount mainaccount;

        LedgerDimensionDefaultAccount   lda;

        

        mainaccount = MainAccount::findByMainAccountId("110110");

        lda = LedgerDefaultAccountHelper::getDefaultAccountFromMainAccountRecId(mainaccount.RecId);

        Info(strFmt("%1",lda));

    }

......................................

Other Way :

  public static void main(Args _args)

    {

        DimensionDynamicAccount     offsetLedgerDim;

        Array                       acctDimAttrArray  = new Array(Types::String);

        acctDimAttrArray.value(1,"MainAccount");


        Array                       acctDimArray     = new Array(Types::String);

        acctDimArray.value(1,'112010');


        DefaultDimensionIntegrationValues DefaultDimensionIntegrationValues   = DimensionResolver::getEntityDisplayValue

            (acctDimAttrArray, acctDimArray, extendedTypeStr(DimensionDynamicAccount), LedgerJournalACType::Ledger);

        DimensionDynamicAccountResolver DimensionDynamicAccountResolver     = DimensionDynamicAccountResolver::newResolver

                (DefaultDimensionIntegrationValues, LedgerJournalACType::Ledger, curExt());

        offsetLedgerDim = DimensionDynamicAccountResolver.resolve();

        info(strFmt("%1",offsetLedgerDim));

    }

After runinng the job a recid will be generated.

if you are getting an error like : No active format for data entities has been set up. Set up an active format for each dimension format type. then do the following step.

in my code i've given a value for main account only, so i have added main account in dimension configuration.


Reference:

https://community.dynamics.com/blogs/post/?postid=ad1c7df5-fff2-43c1-9791-7ad80e545eec

For error resolving :
http://www.dynamicsaxhelp.com/Resolved/No-active-format-for-data-entities-has-been-set-up/46






No comments:

Post a Comment