Create New Default Dimension in AX 2012 using X++ Code

Hi All,

Today, I got time to update my blog with some good piece of code.
The code reflects on how to create Default Financial in AX 2012 using x++ code.

Here’s the sample code written in job

static void setFinancialDimensionToCustomer(CustAccount _custAccount)
CustTable custTable;
Struct struct = new Struct();
container ledgerDimension;
DimensionDefault DimensionDefault;
struct.add(‘BookingChannel’, ’30’);
struct.add(‘Carrier’, ’01’);
struct.add(‘Department’, ’30’);
struct.add(‘Destination’, ’01’);
struct.add(‘Division’, ’30’);
struct.add(‘Origin’, ’01’);
struct.add(‘Product’, ’30’);

ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);

ledgerDimension += struct.fieldName(2);
ledgerDimension += struct.valueIndex(2);

ledgerDimension += struct.fieldName(3);
ledgerDimension += struct.valueIndex(3);

ledgerDimension += struct.fieldName(4);
ledgerDimension += struct.valueIndex(4);

ledgerDimension += struct.fieldName(5);
ledgerDimension += struct.valueIndex(5);

ledgerDimension += struct.fieldName(6);
ledgerDimension += struct.valueIndex(6);

ledgerDimension += struct.fieldName(7);
ledgerDimension += struct.valueIndex(7);

DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable = CustTable::find(_custAccount, true);
custTable.DefaultDimension = DimensionDefault;

Happy DaXing………


2 responses

  1. Hello,
    I got a new requirement in General journal form added Two new button(Generate Template & Upload) created new record by using “Generate template”, in excel manually enter all records including ‘Account,Offset account’ value,
    when i click “Upload button” the current records should be inserted into (Ledger journal Trans) table.
    My issue when i click “Upload” button all records fetching from (Excel) and inserted into (Ledger journal Trans) except 1.Account ,2. Offset account value.
    How should i insert Account and Offset Account values from Excel to Ledger Journal Trans table.
    Please revert back.


    1. what are the datatypes you are using for Account and Offset account value? Are you using string format? for quick fix, give single quote (‘) before value in excel and then import. please let me know if its help or not.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: