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);

Tuesday, November 8, 2011

AX SSRS: Date Range

A sample code to specify date range values (with date format culture used by AX) for AX AOT Query in Data Method of Dynamics AX Reporting Project:

[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static DataTable GetData(DateTime dateFrom, DateTime dateTo)
{
  Dictionary<string, object> ranges = new Dictionary<string, object>
  {
    {"AXTable.DateFieldRange",
      dateFrom.ToString(AxQuery.Culture) + ".." + dateTo.ToString(AxQuery.Culture)}
  };

  return AxQuery.ExecuteQuery("SELECT * FROM AXAOTQuery", ranges);
}

Monday, October 31, 2011

Note to Self: AX SSRS Default (Today) Value for Date Parameter

I find this useful as my copy and paste resource for my Dynamics AX Reporting Project development to create default (today) value for Date parameter:
=DateSerial(Year(NOW), Month(NOW), Day(NOW))

And the properties window snapshot:

Of course, other alternative is by using Datasets as following snapshot (taken from Cust ReportsLibrary):