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 :
Finance | Project Operations, Human Resources, ...
Answered

Find or create financial dimension RecId with specific values

(0) ShareShare
ReportReport
Posted on by 108

Hi all,

I want to find(create if it does not exist yet) the financial dimension RecId that has specific dimension value/s (ex. Cost center - 010)

Does anyone know how can I achieve this?

Thanks in advance.

Regards,

Zoran

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi Zoran,

    Have you checked the dimension attribute value combination table?

    That should hold your information.

    Best regards,

    Ludwig

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    Do you want Ledger Dimension or Default Dimension

    For Ledger;

    LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensionsContainer);

    or

    LedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(_defaultAccount, JournalTrans.DefaultDimension);

    dynamicsax4u.wordpress.com/.../

    For Default;

    msdynamics.nevoitech.com/.../

    And Lastly for complex company structures(container part)

    community.dynamics.com/.../x-code-to-generate-ledger-dimension-based-on-the-company-accounting-structure

  • Zoran Golomeov Profile Picture
    108 on at

    Hi Ludwig,

    thank you for replying.

    I am not sure if its enough to do a search only by the display value in the table you mentioned.

    Problem is that I am not sure how many dimensions will the customer use in the system and i dont want to go through all dimensions  and set them as empty. Also i did a test scenario and set a value on a project and checked the dimension value in sql (DimensionAttributeValueSet table) and the RecId is different than the one I have in the table you mentioned.

    Thanks in advance.

    Regards,

    Zoran

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    I see.

    What do you need this information actually for?

  • Zoran Golomeov Profile Picture
    108 on at

    I have a form with a CostCenter str lookup field.

    Selecting a value from here I need to find(create if it doesnt exists yet) the dimension that holds only cost center value and merge it with a different default dimension.

    Regards,

    Zoran

  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    DimensionDefault defaultDim,newDefaultDim;
    DimensionAttribute                  dimensionAttribute;
    DimensionAttributeValue             dimensionAttributeValue;
    DimensionAttributeValueSetStorage   dimensionStorage;
    ;
    defaultDim              = mytable.Defaultdimension;
    dimensionAttribute      = DimensionAttribute::findbyName("CostCenter");// or find(RecId)
    dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, myDimValue/*newCostCenterValue*/,false,true);
    
    dimensionStorage = DimensionAttributeValueSetStorage::find(defaultDim);
    dimensionStorage.addItem(dimensionAttributeValue);
    
    newDefaultDim = dimensionStorage.save();

    I didn't test it but it didn't look wrong.

    Edit:Sorry, I'm writing from the editor. I updated the code.

  • Zoran Golomeov Profile Picture
    108 on at

    Hi Ergun,

    thank you for your reply.

    The code you provided you cannot compile for reason that you can't pass a buffer of DimAttValue in the find DimensionAttributeValueSetStorage method where a RecId is expected and how do you get 'newValue' and what does it represent?

    Regards,

    Zoran

  • ergun sahin Profile Picture
    8,826 Moderator on at

    Sorry, I'm writing from the editor. I updated the code above. (myDimValue-->come from form field)

  • Zoran Golomeov Profile Picture
    108 on at

    Hi Ergun,

    thank you I think this solves my problem.

    Initial testing shows expected results.

    Best regards,

    Zoran

  • Zoran Golomeov Profile Picture
    108 on at

    Hi Ergun,

    this is 1 issue, if defaultDim already contains a value for the cost center it won't overwrite it with the value I select myDimValue. Only if there is no dimension defined it will do the merging.

    Any suggestions?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans