Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to create a Dimens...
Finance forum

How to create a DimensionAttributeValueCombination for a vendor account

(0) ShareShare
ReportReport
Posted on by 105

I need to create a DimensionAttributeValueCombination record for a Vendor thru code. I have been able to create dimensionAttributeValueCombination for MainAccount with Financial Dimensions. And red that for just a Main Account I have to suppress the financial dimension part code. But when execute the code I receive an error "Function DimensionDefaultingEngine::constructForMainAccountId has been incorrectly called"

this is the code i am using

public static refRecId createMainAccount(str _MainAccount)
{
DimensionServiceProvider DimensionServiceProvider = new DimensionServiceProvider();

LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();
DimensionAttributeValueContract ValueContract;
List ListValueContract = new List(Types::Class);

dimensionAttributeValueCombination dimensionAttributeValueCombination;

DimensionStorage dimStorage;

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


dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);

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

return dimensionAttributeValueCombination.RecId;
}

What I finally need to accomplish is to create a ledger line, but i need to assign a value for the LedgerDimension  when the vendor does not exist in the DimensionAttributeValueCombination table.

Thanks in advance

  • Suggested answer
    Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: How to create a DimensionAttributeValueCombination for a vendor account

    That's correct. For a record with vendor account only main account is going to be 0 . If you want to merge main account with any default dimension you should explore LedgerdimensionFacade class.

  • Mariano Gracia Profile Picture
    on at
    RE: How to create a DimensionAttributeValueCombination for a vendor account

    Your post is a bit confusing for me, DIMENSIONATTRIBUTEVALUECOMBINATION allways contains a Main Account, what are you trying to achieve?, you can create a ledger journal line with a vendor account and add financial dimensions to that line, is this that what are you trying to do through code?:

    VEND_5F00_DIMENSION_5F00_2.JPG

    VEND_5F00_DIMENSION_5F00_2.JPG

  • Emilio Molina Profile Picture
    105 on at
    RE: How to create a DimensionAttributeValueCombination for a vendor account

    Thanks a lot for jour post. I reviewed and test your code.  I was able to create a record in the DIMENSIONATTRIBUTE table as well as in the DIMENSIONATTRIBUTEVALUE table but I did not find a method for creating a value in the DIMENSIONATTRIBUTEVALUECOMBINATION without a main account. I reviewed the records created in the DIMENSIONATTRIBUTEVALUECOMBINATION for vendors and the MainAccount column is set to 0. Do you have any idea of how to create a record in this table for a vendor account alone. Without any other associated dimensions?

    Thanks in advance

  • Suggested answer
    Sukrut Parab Profile Picture
    71,682 Moderator on at
    RE: How to create a DimensionAttributeValueCombination for a vendor account

    You can take a look at this link to see examples

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,043 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,864 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans