View Method Ax View

Created a static method on a View.

and attached it to a field on the view .

how do i access current row inside the method so i can maninpulate each row values and return the value. which can be assigned ot the new field.

private static server str method1()
{
TableId viewId;
View3 view3;
str accNum;

Query query;
// QueryRun queryRun;
QueryRun runner;
QueryBuildDataSource ds;

DictView dictView2;

#define.DataSourceName(“GeneralJournalAccountEntry_1”)
#define.FieldLedgerNum(“LedgerDimension”)
#define.ViewName(TrvExpenseView);

dictView2 = new DictView(tableNum(#ViewName));

accNum = dictView2.computedColumnString(#DataSourceName,
#FieldLedgerNum,
FieldNameGenerationMode::FieldList,true);
//_args = new Args();

viewId = tableNum(View3);

query = new Query();
ds = query.addDataSource(viewId);
ds.addRange(fieldNum(View3,RecId)).value(accNum);
ds.addRange(fieldNum(View3,Ordinal)).value(‘1’);

runner = new QueryRun(query);

while(runner.next())
{
view3.data(runner.get(viewId));

}

return view3.DisplayValue;
}

i found the solution . if we read carefully this post .

http://community.dynamics.com/product/ax/axtechnical/b/daxmusings/archive/2011/10/18/computed-view-columns-in-ax-2012.aspx

thanks to Joris dG

we can access current row in ViewMethod Attached to a field on the View .

using

``

 SysComputedColumn::returnField(
            tableStr(SalesLineView),
            identifierStr(SalesLine),
            fieldStr(SalesLine, SalesPrice))

this returns the SalesPrice of each row of SalesLineView.

this might help some one else who migh be in the same situation.

``