Tuesday, 20 March 2012

Calling Axapta 2009 Static Method from outside the domain using LogonAs

Dear All here is an article to how to call an Axapta static method from outside the domain server through a web service and business connector

Dim creds As New System.Net.NetworkCredential()
creds.Domain = ConfigurationSettings.AppSettings("Domain").ToString '
creds.UserName = ConfigurationSettings.AppSettings("ProxyName").ToString
creds.Password = ConfigurationSettings.AppSettings("ProxyPassword").ToString            ax.LogonAs(ConfigurationSettings.AppSettings("AdminName").ToString,ConfigurationSettings.AppSettings("Domain").ToString, creds, "", "", ConfigurationSettings.AppSettings("AXServer").ToString, "")

ax.CallStaticClassMethod("ClassName", "MethodName",)


Note: Be sure that the proxy user name and password will be the proxy defined inside the Axapta which we can get from here Administration > Setup > Security > System Service account
Above the business connector  there is the alias name and the domain which we will use in the Network Credential parameters

Tuesday, 13 March 2012

JQuery methods dose not work after calling any ajax event

After doing any event from any ajax controls i found that the JQuery code dose not work this is happening because of any Ajax event is removeing the scripts which is loaded at first time when we open the page,  so we need to load again each time the functions of the JQuery after each Ajax event.

Here below an example for what i did to fix these problem

$(document).ready(function () {



function load() {

function EndRequestHandler() {

    $("#pHeader1").click(function () {

    $("#pHeader2").click(function () {

    $("#pHeader3").click(function () {

EndRequestHandler function is a function include inside it all the JQuerys calls and the function Load() where we add all the JQuery code again after firing any ajax event

ASP.NET Print a crystal report by code to a specific printer via printer IP and Name

 Dim rdpDocument As New ReportDocument
            Dim crConnectionInfo As New ConnectionInfo()

            crConnectionInfo.ServerName = "MIS-009"
            crConnectionInfo.DatabaseName = "HR_DEV"
            crConnectionInfo.IntegratedSecurity = False
            crConnectionInfo.UserID = "sa"
            crConnectionInfo.Password = "sa"

            rdpDocument.SetDatabaseLogon("sa", "sa")

            rdpDocument.SetDataSource(GetData("@PICKINGROUTEID", "034333_138", "REPORT_TRUCK_CONSIGNMENT"))
            rdpDocument.PrintOptions.PrinterName = "\\\" & "HP Color LaserJet 4700 PS"
            rdpDocument.PrintToPrinter(1, True, 0, 1)         

If you faced any problem or error related to that you can not identify the printer IP or address here some steps to get the printer address

1) Add Printer to server. 2) run regedit 3) Search for printername to find your printer 4) value of uNCName property is printer name you need. oRpt.PrintOptions.PrinterName = "value";

Monday, 12 March 2012

Axapta 2009 create a new sales line


         inventdim.InventLocationId = SalesTable::find(salesid).InventLocationId;
         inventdim.inventBatchId = _HBInventTx_D_V2.inventBatchId;
         inventdim = inventdim::findOrCreate(inventdim);

         _SalesLine.InventDimId = inventdim.inventDimId;
         _SalesLine.SalesId = salesid;
         _SalesLine.ItemId = _HBInventTx_D_V2.ItemId;
         _SalesLine.SalesQty = _HBInventTx_D_V2.qty * -1;
         _SalesLine.ReturnReasonCodeId = '01';

         _SalesLine.createLine(NoYes::Yes, // Validate
                               NoYes::Yes, // initFromSalesTable
                               NoYes::Yes, // initFromInventTable
                               NoYes::Yes, // calcInventQty
                               NoYes::Yes, // searchMarkup
                               NoYes::Yes); // searchPrice

Windows Mobile set the device date and time

 <DllImport("coredll.dll")> _
   Private Function SetSystemTime(ByRef time As SYSTEMTIME) As Boolean
    End Function

Public Sub setDeviceDateTime(ByVal dt As DateTime)
        Dim ServerTime As New SYSTEMTIME

        ServerTime.Day = dt.ToUniversalTime.Day
        ServerTime.Month = dt.ToUniversalTime.Month
        ServerTime.Year = dt.ToUniversalTime.Year
        ServerTime.Hour = dt.ToUniversalTime.Hour
        ServerTime.Minute = dt.ToUniversalTime.Minute
        ServerTime.Second = dt.ToUniversalTime.Second

    End Sub
    Public Structure SYSTEMTIME
        Public Year As Short
        Public Month As Short
        Public DayOfWeek As Short
        Public Day As Short
        Public Hour As Short
        Public Minute As Short
        Public Second As Short
        Public Milliseconds As Short
    End Structure