Job to update customer financial dimension in dynamics ax 2012

Another usefull job for updating the Customer financial dimension in dynamics ax 2012. I hope, that would be useful for Techies.

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

Comments

Popular posts from this blog

Dynamics Ax 2012 Interview Questions:

Oops concept in AX