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)

Create a new record in dimensionAttributeValueCombination, by AX2012 code.

(0) ShareShare
ReportReport
Posted on by 425

this is not a question but may be an answer. 

several questions i had this forum have answered me. so i just want to share my contribution.

<-------

Create a new record in dimensionAttributeValueCombination, by AX2012 code.

in ax2012 journal voucher lines, when you key in Ledger account+dimensions information, system will create a record in table dimensionAttributeValueCombination.

this is how i do it in ax2012 coding.  the container _c  contains the information LedgerAccount and dimensions.

it worked for me.

------->

refRecId getLedgerDimension(container _c)
{
    DimensionServiceProvider    DimensionServiceProvider = new DimensionServiceProvider();
    LedgerAccountContract       LedgerAccountContract = new LedgerAccountContract();
    DimensionAttributeValueContract ValueContract;
    List                            ListValueContract = new List(Types::Class);

    dimensionAttributeValueCombination  dimensionAttributeValueCombination;

    DimensionStorage                    dimStorage;

    str         _ledgerAccount = conPeek(_c, #Account);
    str         _department = conPeek(_c, #Department);
    str         _location = conPeek(_c, #Location);
    str         _region = conPeek(_c, #Region);
    str         _zone = conPeek(_c, #Zone);
    str         _company = conPeek(_c, #Company);

    if (_department)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Department') ;
        ValueContract.parmValue(_department);
        ListValueContract.addEnd(ValueContract);
    }

    if (_location)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Location') ;
        ValueContract.parmValue(_location);
        ListValueContract.addEnd(ValueContract);
    }

    if (_region)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Region') ;
        ValueContract.parmValue(_region);
        ListValueContract.addEnd(ValueContract);
    }

    if (_zone)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Zone') ;
        ValueContract.parmValue(_zone);
        ListValueContract.addEnd(ValueContract);
    }

    if (_company)
    {
        ValueContract = new DimensionAttributeValueContract();
        ValueContract.parmName('Company') ;
        ValueContract.parmValue(_company);
        ListValueContract.addEnd(ValueContract);
    }

    LedgerAccountContract.parmMainAccount(_ledgerAccount);
    LedgerAccountContract.parmValues(ListValueContract);

    dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);

    dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());

    return dimensionAttributeValueCombination.RecId;
}

 

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ramprasadrao@hotmail.com Profile Picture
    5 on at
    RE: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    thank you

  • Pedro Rodriguez Profile Picture
    2,245 on at
    Re: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    For a Vendor (same for customer) this would make the work:

    LedgerDimensionAccount  ledgerDim;

    ledgerDim = DimensionStorage::getDynamicAccount(‘VEN-00273′, LedgerJournalACType::Vend);

    info(strFmt("%1 -%2", ledgerDim, DimensionAttributeValueCombination::find(ledgerDim).DisplayValue));

    The values would be created if they already doesnt exists.

  • Fayaz Ahamed Profile Picture
    1,420 on at
    Re: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    Remove all 'if' conditioned code. remaining will serve,what you required!

  • YasirGodil Profile Picture
    204 on at
    Re: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    How to do it only for main account means I have no other dimensions I need to create record only for main account ?

  • Suggested answer
    Community Member Profile Picture
    on at
    Re: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    Thanks dude.

  • Fayaz Ahamed Profile Picture
    1,420 on at
    Re: Create a new record in dimensionAttributeValueCombination, by AX2012 code.

    Thanks Mel. Great article!

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans