The views and opinions expressed in this blog are those solely of the author(s) and do not necessarily reflect Microsoft’s current policy, position, or branding. For official announcements and guidance on Dynamics 365 apps and services, please visit the Microsoft Dynamics 365 Blog.
Personalized Community is here!
Quickly customize your community to find the content you seek.
Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
Default dimensions are used very commonly in D365FO and DAX 2012. During development or customization of the system, it is very common that we often stuck at the time when we have to create default dimension using our own dimension values. To solve this problem, I am sharing this code. You just have to alter dimension names, values, arguments and no. of arguments.
Note: I am using three arguments, inserting values to three dimensions and getting DimensionDefault value for it. You can do this for one dimension or as many dimensions as you want.
//Change the arguments (variable) names and assign names as per your requirements
//Change in the function as well
public DimensionDefault createDefaultDimension(str department, str purpose, str costCenter)
DimensionAttributeValueSetStorage valueSetStorage = new DimensionAttributeValueSetStorage();
//Change the dimension names. Use the dimension name which are open and active in the system
//I have given Region, Purpose and Costcentre just for an example
container conAttr = ["Region", "Purpose", "Costcentre"];
//Change the values which you want to set in dimensions. Use values which are open and active in the system
//I have given the arguments of function as values for dimensions.
//Dimension name -> dimension value
//Region -> department
//Purpose -> purpose
//Costcentre -> costCenter
container conValue = [department, purpose, costCenter];
for (i = 1; i <= conLen(conAttr); i++)
dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
if (dimensionAttribute.RecId == 0)
dimValue = conPeek(conValue,i);
if (dimValue != "")
dimensionAttributeValue = dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
result = valueSetStorage.save();
//It reutrns the value of type DimensionDefault
Moreover, if you have more ways to create default dimension, kindly share them in comments.
Github: https://github.com/moeenahmedsultan/msdynamics/blob/master/create default dimensions using x++
Do all things with love, passion and dedication! – Patrick Driessen
The post Create default dimension using x++ appeared first on NevoiTech Blog.
Business Applications communities