How does one create a calculated field in a View (AX 2009)

Hi,

I am trying to create a calculated field / formula for a view in AX 2009. Can you tell me if there is a way I can write a method, and have the view call this method?

My view is in AOT → Data Dictionary → View - > My_View_Name

I want to see if my method in the view can return a Data Type (String / Number), and use this data type in the display of the view. Is this possible? If yes, can you provide me the steps.

Thanks,

Kumar

This can be done by performing the following steps -

  1. Create a Method in a View.

display MyDataType calculatedAmount()

{

;

return (this.AmountMST - this.uerAmountOffset); // These fields are part of the select in the view

}

  1. Create an Extended Data Type called MyDataType in AOT - > Data Dictionary → Extended Data Type

  2. Create a New Field Group within the view

  3. Add the newly created method calculatedAmount to the newly created Field Group.

The calculated field should show up in your view / report

Regards,

Kumar

I just experimented with this in AX2009.

  • Added a new field to the table, but the Save Contents property is No.
  • Created a new view that uses the table.
  • On the view, I overrode the PostLoad method and populated the new field.
  • Added the field to the Fields node of the view.
  • Opened the view in Table Browser.

Much like a display method, I can see the data but can’t really sort or select on it. You can try, but you get an error because the field is not stored in the database (because Save Contents is No).