Wednesday, November 16, 2011

AX SSRS: CreateAxaptaRecord, CallStaticClassMethod, and CallStaticRecordMethod Sample Code

A sample code to get text of an item dependent on the (AX) user language in Data Method of Dynamics AX Reporting Project:

AxaptaWrapper axSession = SessionManager.GetSession();

AxaptaRecordWrapper userInfo =
  axSession.CreateAxaptaRecord(
    axSession.CallStaticClassMethod("xUserInfo", "find"));

AxaptaRecordWrapper inventTable = 
  axSession.CreateAxaptaRecord(
    axSession.CallStaticRecordMethod("InventTable", "find""ItemId"));

String itemText =
  (String)inventTable.Call("txt", userInfo.GetField("language"));


The AX code to get similar result is:

return InventTable::find("ItemId").txt(xUserInfo::find().language);

No comments:

Post a Comment