SysComputedColumn implementation to add Computed Column in Dynamics Ax 2012 View

The purpose of this blog is to explore the new feature in dynamics ax 2012 through which you can use the computed columns in Dynamics ax View, complete class SysComputedColumns is available in AOT with lots of method in it. You can add any more based on your requirement and use them in your View as i have explained below through example.

1)     Create a method on SysComputedColumn class similar to:

publicstatic clientserver str len(str _expression)
{
return ‘LEN(‘ + _expression +’)’;
}

2)     Create a new view or select any existing and select the normal fields you want to the view from its datasource.

3)     Create a method on the view similar to:

publicserver staticstr mainAccountLength()
{
tableName viewName =tablestr(AbcTest);       // name of your view
str mainAccountLength;

mainAccountLength = SysComputedColumn::len(
SysComputedColumn::returnField(viewName,identifierStr
(MainAccount_1), fieldstr(MainAccount, name)));

//identifierStr(MainAccount_1) = name of the datasource in the view.

return mainAccountLength;
}
(I used \Data Dictionary\Views\ProjTransBudgetCube\Methods\projBudgetPayrollAllocation as a baseline)
The purpose here in this example is to use the computed column in Dynamics ax 2012 View.

4)     Rightclick on the view fields node and select new INT computed column

5)     Set the viewmethod = mainAccountLength (the method created above)

Another blog that also gives you an example about adding a computed columns in View

 

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: