Question Status

Verified
PhilSM asked a question on 30 Mar 2012 5:26 AM

In the ForecastSales table I would like to add a method to return the first three characters of the Customer type (Dimension).

The field length is 10 characters but I want to return the first three

e.g.

GEN01, GEN02, GEN03 would all return GEN

 

display Dimension dimension()
{
    str CustDimTrim;

    CustDimTrim = subStr(this.Dimension,1,3);

    return CustDimTrim;

}

Reply
Verified Answer
Matthew Feist [MSFT] responded on 2 Apr 2012 9:32 AM

Hello PhilSM!

In AX 2009, the product shipped with three default dimensions out of the box, Department, CostCenter, and Purpose. So this Customer dimension is most likely a customization that you’ve added. The Dimension Extended Data Type is array based so you’ll need to know which element in the array represents your Customer data. That can be found by browsing to the following node in the AOT:

AOT\Data Dictionary\Extended Data Types\Dimension\Array Elements

 

Once you know which element of the array represents that Customer data, you can use the following code below, by replacing ‘x’ with that index. Also note, I’ve modified the return type of the method to simply ‘str’, as we only want to return a string.



public
display str dimensionPrefix()

{

    str customerPrefix;

   

    // Only grab the first three characters of the customer dimension

    customerPrefix = subStr(this.Dimension[x], 1, 3);

   

    return customerPrefix;

}

Reply
Verified Answer
Matthew Feist [MSFT] responded on 2 Apr 2012 9:32 AM

Hello PhilSM!

In AX 2009, the product shipped with three default dimensions out of the box, Department, CostCenter, and Purpose. So this Customer dimension is most likely a customization that you’ve added. The Dimension Extended Data Type is array based so you’ll need to know which element in the array represents your Customer data. That can be found by browsing to the following node in the AOT:

AOT\Data Dictionary\Extended Data Types\Dimension\Array Elements

 

Once you know which element of the array represents that Customer data, you can use the following code below, by replacing ‘x’ with that index. Also note, I’ve modified the return type of the method to simply ‘str’, as we only want to return a string.



public
display str dimensionPrefix()

{

    str customerPrefix;

   

    // Only grab the first three characters of the customer dimension

    customerPrefix = subStr(this.Dimension[x], 1, 3);

   

    return customerPrefix;

}

Reply