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);

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

Happy DaXing………

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: