Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Find or create financial dimension RecId with specific values

Posted on by 105

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

  • Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    RE: Find or create financial dimension RecId with specific values

    Yes, he did - the reply from Ergün is marked as a verified anwers. If it doesn't work for you, please explain your particular situation in your thread Find or create financial dimension RecId for time sheet integration (where I already replied to you).

  • AXDynamics365 Profile Picture
    AXDynamics365 58 on at
    RE: Find or create financial dimension RecId with specific values

    Hii Zoran ,

    I have the same requirement you had

    did you found the answer

    please let me know and share the code  

  • Zoran Golomeov Profile Picture
    Zoran Golomeov 105 on at
    RE: Find or create financial dimension RecId with specific values

    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?

  • Zoran Golomeov Profile Picture
    Zoran Golomeov 105 on at
    RE: Find or create financial dimension RecId with specific values

    Hi Ergun,

    thank you I think this solves my problem.

    Initial testing shows expected results.

    Best regards,

    Zoran

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: Find or create financial dimension RecId with specific values

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

  • Zoran Golomeov Profile Picture
    Zoran Golomeov 105 on at
    RE: Find or create financial dimension RecId with specific values

    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

  • Verified answer
    ergun sahin Profile Picture
    ergun sahin 8,812 Super User on at
    RE: Find or create financial dimension RecId with specific values

    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
    Zoran Golomeov 105 on at
    RE: Find or create financial dimension RecId with specific values

    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

  • Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Find or create financial dimension RecId with specific values

    I see.

    What do you need this information actually for?

  • Zoran Golomeov Profile Picture
    Zoran Golomeov 105 on at
    RE: Find or create financial dimension RecId with specific values

    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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans