Tuesday, October 1, 2013

[AX 2012] SSRS: Excel sheet name

If you save a SSRS report to an Excel and you want to control the sheet name, you will not be able to do it via Visual Studio. You have to do it via SQL Server Report Builder because the PageName property is not available at Visual Studio (and AX).

[AX 2012] Note to Self: Get Dimension Value of An Attribute

A sample code to get a value of an attribute dimension:

static void MyJob(Args _args)
{
  info(
    DimensionAttributeValueSetStorage::find(
      SalesLine::findRecId(1234567890).DefaultDimension)
        .getDisplayValueByDimensionAttribute(
          DimensionAttribute::findByName("AttributeName").RecId));
}

Sunday, April 7, 2013

[AX 2012] Personalization (form): add a field to a list page form and reposition the field

Have you ever tried to add a field to a list page form and reposition the field but if you re-open the list page form, the new field is not at the desired position?

For example: I add the address field from the Addresses table to the customer list page form and reposition the field as the third column on the list page grid.


If I re-open the customer list page form then I will see that my added address field position is not as my personalization (at the first column instead of at the third column).

I know one way to make it work: Change the AutoDeclaration property of ListPageGrid to Yes.



Is there another way to make it work?

Friday, January 13, 2012

AX SSRS: Use AX Label with localization

To use AX label with localization, you can wrap SysLabel::labelId2String static method or SysLabel::labelId2String2 static method in a data method and call it in the design:

[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
public static String GetLabel(String labelId, String languageId)
{
    return SessionManager.GetSession().CallStaticClassMethod(
                          "SysLabel", "labelId2String2", labelId, languageId);
}


and use it: =GetLabel("@SYS103105", User!Language)

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