Tuesday, April 21, 2015

Debugging AIF Services in AX 2012

Regardless of the adapter type you choose, services in AX 2012 run as IL code - even if you are using the file adapter.  To debug IL code
you must use Visual Studio.
The steps for debugging a service are:
  1. On the AOS, install the AX Application Explorer from the Microsoft Dynamics AX CD by choosing the
    component Developer Tools, and then click Visual Studio Tools.  If the AX debugger is not installed,
    you will also need to install it.
  2. Open Visual Studio, create a new project, and in the AX Application Explorer find the methods in the
    service classes that are of interest.
  3. In Visual Studio add breakpoints where needed.
  4. Click Debug, and then click Attach to Process.
  5. Mark the checkboxes for Show processes from all users and Show processes in all sessions.
  6. Select AX32Serv.exe and click Attach.The Ax32Serv.exe won't be able available if you are not debugging on the AOS, so
    you need to be on the AOS.
  7. In a separate instance of VS (so have two different projects/solutions open) run the code that calls
    the service.One instance to run the code that
    calls the service and another instance of VS to do the debugging.  By
    having two instances open, you can leave the debugging instance attached to the
    AOS while you run the service code over and over again.

Tuesday, April 14, 2015

Standard Document Services 2012

You can find a complete list of standard AIF document services on TechNet.

Here is the link.  

Troubleshoot services and AIF


While looking for a solution of an issue related to AIF  I found an interesting article on TechNet for troubleshooting  AIF common issues that we face in document exchanges.I hope that will be helpful for some of you.

Here is the link.

Debugging code in AIF classes


 
There is a Piece of code in \Classes\AifOutboundProcessingService\run or \Classes\AifInboundProcessingService\run

runas(message.sourceEndpointAxUserId(),
                        classnum(AifInboundProcessingService),
                        staticmethodstr(AifInboundProcessingService, processAsUser),
                        [message.pack(), messageId]);

just comment this code and change the scope of the static method processAsUser from the same class to public and then call it exactly as below in the run method

                             AifInboundProcessingService::processAsUser([message.pack(), messageId]);

This would allow you to debug the code in Aif and the Axd's but make sure you delete these changes once you complete your debugging.


Enterprise Search in Dynamics AX 2012


Enterprise search allows MS Dynamics AX 2012 users to search for common nouns, such as 'customer' and 'cash flow report.' Users can also search for specific data, such as a customer name, product ID, telephone number, address etc. It enables users to search through data, metadata, and documents that are attached to records by using either the Microsoft Dynamics AX client or Enterprise Portal for Microsoft Dynamics AX.

Below are TechNet links to to install and configure enterprise search.

Enterprise Search

Enterprise Search configuration 


Sales Order Confirmation through code

Few days earlier i got a  requirement from client to auto confirm a sales order after creating a sales order(importing SO xml) using standard sales order document service. Here is the code for sales order conformation. 

public boolean confirmSalesOrder(SalesId _salesId)
{
     SalesFormletter SalesFormletter;
    SalesTable SalesTable;

    SalesFormletter = SalesFormletter::construct(DocumentStatus::Confirmation,true);

    SalesTable = SalesTable::find(_salesId);

    SalesFormletter.update(SalesTable,
                                              systemDateGet(),
                                              SalesUpdate::All,
                                              AccountOrder::None,
                                              false,
                                              false);

}

I Added this method in AxdSalesOrder class and called it after SO record was created in AX. 
In next few days i am going to share more information on AIF, EP and other AX stuff.