In this article we will see how to set financial dimension combination for a PurchLine using X++ code.
Please follow the code below to set the financial dimensions.
PurchLine purchLine; DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage; DimensionAttributeValue dimensionAttributeValue; DimensionAttribute dimensionAttribute; container financialDimensionName; container financialDimensionValue; int i; financialDimensionName = ['BusinessUnit', 'CostCenter', 'Department', 'ItemGroup', 'Project']; financialDimensionValue = ['001', '007', '022', 'AudioRM', '000002']; purchLine = PurchLine::find('000038', 1); dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage(); for (i = 1; i <= conLen(financialDimensionName); i++) { dimensionAttribute = DimensionAttribute::findByName(conPeek(financialDimensionName, i)); dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, conPeek(financialDimensionValue, i), false, true); if (dimensionAttributeValue) { dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue); } } ttsBegin; purchLine.selectForUpdate(true); purchLine.DefaultDimension = dimensionAttributeValueSetStorage.save(); purchLine.update(); ttsCommit;
You can use the same code for others like Sales line etc. just replace the PurchLine buffer with the SalesLine etc.
Thank you for reading this article hope you find it useful.
Technical Consultant
Microsoft Dynamics CRM is a powerful Customer Relationship Management (CRM) tool that helps businesses manage…
Today we will be going over the steps how to assign owner to specific Team…
Today we will be going over the steps how to set the value of a…
In this article we will see how we can create and post free text invoice…
In this article we will be focusing on confirmation of a sales order using X++…
In this article we will be focusing on confirmation of a purchase order using X++…