Wednesday 17 December 2014

SSRS Report values of Company Heading , Page Numbers, Date And Time Printing and Row Numbers

Hi Friends,

Today we will use simple ways to print on the textbox

Company Information
=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.PostDataMethodEvaluation(Microsoft.Dynamics.Framework.Reports.DataMethodUtility.
UpdateAxContextPartition(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Parameters!AX_RenderingCulture.Value, Parameters!AX_PartitionKey.Value),Microsoft.Dynamics.Framework.Reports.DataMethodUtility.GetFullCompanyNameForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value))

Page Numbers On the Header Section

=System.String.Format(Labels!@SYS182566, "" & Globals!PageNumber & "", "" & Globals!TotalPages & "")

Date And Time Printing on the Header Section

=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.PostDataMethodEvaluation(Microsoft.Dynamics.Framework.Reports.DataMethodUtility.UpdateAxContextPartition(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Parameters!AX_RenderingCulture.Value, Parameters!AX_PartitionKey.Value),Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "d", Parameters!AX_RenderingCulture.Value)) & vbCrLf & Microsoft.Dynamics.Framework.Reports.DataMethodUtility.PostDataMethodEvaluation(Microsoft.Dynamics.Framework.Reports.DataMethodUtility.UpdateAxContextPartition(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, Parameters!AX_RenderingCulture.Value, Parameters!AX_PartitionKey.Value),Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, System.DateTime.UtcNow, "t", Parameters!AX_RenderingCulture.Value))

To Print the row numbers in the Grid

=RowNumber(Nothing)

Vivek Chirumamilla

Monday 15 December 2014

C# code to use in Ax for fetching records

Hi Friends,

Here is the C# sharp code to login and retreive records in Ax

using System;
using System.Data;
using System.Security.Permissions;
using Microsoft.Dynamics.Framework.Reports;
using System.Data.SqlClient;

public partial class test
{

[DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
public static System.Data.DataTable DataMethod1()
{

System.Data.DataTable customers2 = new DataTable();
string queryString = "SELECT * FROM dbo.CustTable";

SqlConnection connection = new SqlConnection();
connection.ConnectionString =
"Data Source=@server;" +
"Initial Catalog=@DB;" +
"Integrated Security=SSPI;";

SqlCommand cmd = new SqlCommand(queryString, connection);

connection.Open();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());

return dt;


}

}




Vivek Chirumamilla

Tuesday 25 November 2014

Financial Dimension values in Ax 2012


Hi Friends ,

In Ax Financial Dimensions are widely used. In Ax 2012 these dimensions are not at all individual fields, all these Financial dimensions are combined into a single field Default Dimension. This default dimension carry reference to a set of Financial dimension.

The question is how do we get single value of the dimension or all the set of values using this financial dimensions. Here is the sample code which gives the values of financial dimensions.

public static SysDim DefaultDimensionValue(DimensionDefault _dimensionDefault, Description _nameofDimension)
{

DimensionAttributeValueSetStorage dimensionStorage;
Counter i;
SysDim nameofDimension;


// Get dimension storage
if (_dimensionDefault)
{
dimensionStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);

for (i=1 ; i<= dimensionStorage.elements() ; i++)
{
if (DimensionAttribute::find(dimensionStorage.getAttributeByIndex(i)).Name == _nameofDimension)
{
nameofDimension= dimensionStorage.getDisplayValueByIndex(i);
break;
}
else
{
nameofDimension= '';
}
}
}

return nameofDimension;
}

The above sample code gives values dimension value if you have default dimesion and name of Dimension. If you want all the values just tweak this code a little bit.

Vivek Chirumamilla

Wednesday 29 October 2014

How to get the last Activated Form

Hi Friends

Check this

formRun = infolog.parmLastActivatedForm().object();
tableReference = formRun.docCursor().TableId;

Vivek Chirumamilla

Tuesday 28 October 2014

Address System in Ax 2012 R3

Hi Friends,

Ax 2012 has a complex Address when compared to the previous versions of Ax.

In this address is not directly linked to the Customer or Vendor directly.

Customer or Vendor has Party which is linked to the DirParty.

DirParty Contains the Primary postal address reference to Logistics Location RecId which is reflected in LogisticsPostalAddress.

In short Dirparty contains the value of Location for searching address in LogisticsPostalAddress.

Vivek Chirumamilla