Pages

Showing posts with label Integration. Show all posts
Showing posts with label Integration. Show all posts

Saturday, March 4, 2017

Custom AIF operation in Microsoft Dynamics AX 2009

Today let's try to create custom operation on generated by AX AIF Wizard service code.

1. Create new method and write code. 




2. Find you service object in AOT and Add service operation. Select checkbox and press OK.


3. In Visual Studio  add reference to your service.


4. Now can call your custom AX method  in C# code.

private int GetEmplVacationDays(string _emplID, DateTime _from, DateTime _to)
{
    var emplServiceClient = new goEmplTableServiceClient();
    int ret;
    
    try
    {
        ret = emplServiceClient.calcDays(_emplID, _from, _to);
    }
    catch (Exception xException)
    {
        ret = 0;
    }

    return ret;
}

Exposing display methods by AIF in Microsoft Dynamics AX 2009

Sometimes you need to send by AIF data display methods. In my case I have created AIF for EmplTable and additionally I would like to send full name.

1. Find in generated by AIF Wizard classes, class starts with Ax*. In this case it is AxEmplTable.
Write additional parm method returning full name.


2. Save class, Refresh Services, press Generate and do iisreset on IIS Server from command prompt.


3. In Visual Studio Update Service References.



4. Now I can see FullName on my fields list.



Sunday, September 25, 2016

Document Data Sources and integration with Excel

On below video you can watch how to create document data sources service. Document data sources are used to integrate AX Queries with Excel. Excel must have installed PowerPivot plugin . Data from Document Services are only read-only. This integration can be used to create small, simple Bi system in your company.


You can also connect Document Services with Visual Studio. Just add service reference with correct address.
You can see example, written in C#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ODATA_Test.MAN_CustomersNS;
using System.Net;

namespace ODATA_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var uri = new Uri("http://192.168.20.6:8104/DynamicsAx/Services/ODataQueryService" );
            ODataQueryService service = new ODataQueryService(uri);
            service.Credentials = new NetworkCredential { UserName = "***", Password = "***" , Domain = "***" };

            var query = from c in service.MAN_Customers
                        select c;

            foreach (MAN_Customers item in query)
            {
                Console.WriteLine(item.CustTable_AccountNum + " "   + item.DirPartyTable_Name);
            }

            Console.ReadKey();
        }
    }
}