Pages

Thursday, January 22, 2009

Adding simple display fields on VS reports

One thing I feel is missing from the documentation for AX Visual Studio reports is a simple explanation or demo of how to create an old school display field in a report.

I could figure out that a DataMethod was needed but it took me some time to figure out how connect the method with a field on the report and how to pass parameters to the DataMethod.

You add a datamethod like this:
...
[DataMethod(), AxSessionPermission(SecurityAction.Assert]
public static string DataMethod1(string itemId)
{
string demoString = '(' + itemId + ')';

return demoString;
}

Then add a field to your design, and in the Expression editor for the field add the code to call your datamethod:

=DataMethod1(Fields!ItemId.Value)

No comments: