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
wow, awesome blog post. Awesome.
Howdy! I just wish to give you a huge thumbs up foryour great info you have got here on this post.I will be returning to your blog for more soon.
Good way of explaining, and pleasant article to obtain information regarding my presentation focus, which i am going to convey in college.
All those guidelines In addition worked to be a good way to recognize that other people on the internet hold the similar fervor like mine to grasp great deal a lot more all around this condition.
Hello! I could have sworn Iíve been to this blog before but after going through some of the posts I realized itís new to me. Anyways, Iím definitely happy I found it and Iíll be book-marking it and checking back often!
Awesome blog article.Much thanks again. Really Great.
I always was interested in this topic and stock still am, thankyou for posting.
I truly appreciate this article. Will read on…