Posts Tagged ‘integration’

Quick Excel report – Dynamics Ax 2009

May 9, 2011 7 comments

Excel is the most convenient software to examine changes in data. Specially when you have made them code and wanted it to be tracked. That’s is one of the many reasons why excel tops to be the most used software in the world.

This article in detail will tell you how to create an ad hoc excel sheet just in case you wanted to show data changes, compile information from different tables etc.

Create a similar code for your need. [Follow inline comments to understand the code]

static void JobExportToExcel(Args _args)
    SalesLine  salesLine, oldSalesLine;
    str        text;
    TextIO     io;

    //Column header for the excel. The header fields and the data field must match
    //in number and order
    //You can use anything as a delimiter but # is convenient as this rarely appears
    //as data (other choices ~, |)
    text = 'Order # Customer # Item # Lot id # New tax group # Old tax group \n';

    select * from salesLine
             where salesLine.TaxItemGroup == 'GST' ||
                   salesLine.TaxItemGroup == 'Free';

    while (salesLine)
        //save this incase you wanted to show the old value
        oldSalesLine = salesLine.orig();

        if (salesLine.TaxItemGroup == 'GST')
            salesLine.TaxItemGroup = 'CAPITAL';
            salesLine.TaxItemGroup = 'Free';

        //append the text
        text += strfmt('%1 # %2 # %3 # %4 # %5 # %6 \n', salesLine.SalesId, salesLine.CustAccount, salesLine.ItemId, salesLine.InventTransId, salesLine.TaxItemGroup, oldSalesLine.TaxItemGroup);

        //do it after the update text otherwise you loose the orig

        next salesLine;

    //So far no excel :-)...that comes later
    io = new TextIO(WinAPI::getFolderPath(#CSIDL_DESKTOPDIRECTORY) + '\\exportToExcel.txt', 'w');

You can continue to either watch the video or text based on your convenience.

step 1.  Create a delimited text IO file through a job as shown above

step 2.  Open Excel (Don’t try rightclick open with).

setp 3. Click Open file -> Select “ALL files” in the export dialog

step 4: select the textIO file that was recently given

step 5: Specify delimited in the dialog and enter the delimiter (# in this case)

step 6. Click finish your data is in. 🙂  Just format the column size.

Running a .Net reference code in the Server in Dynamics Ax

February 8, 2011 2 comments

We have been recently building some .Net solutions for our vertical. I have consolidated my learnings from it and publishing here as a post.

1. Adding a .Net reference can be as easy as just to drop the dll in the client bin folder and then add it. But if you want the code to execute on the server then this wont work. You will have to publish the dll in the server “GAC(Global Assembly Cache)”.  A assembly on the cache executes on the server.  Look here for articles on publishing a dll to the cache (GAC Publishing) and assigning strong name to it (Assigning Strong Key).

2. When you look at for the GACUtil, you will find it in different places in different pc. The general places to look at are,

-> C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin

-> C:\WINDOWS\Microsoft.NET\Framework\

3. Every time you change and build the solution you have to un publish/publish it to the GAC. This can be difficult to do it manually. The easiest way is to add the following lines in your Project -> Properties -> Post-build event command line  in your visual studio project.

//uninstal old version

“gacutil.exe -u $(TargetName)”

//register new version

“gacutil.exe -i $(TargetPath)”

4. Though you run the code on the GAC it is necessary that the dll is added to all the clients just for compilation. It need not be updated as you revise your dll.

5. If the code is present in a server call then it is required to restart the server every time you re publish a new version to the GAC.  What i found better was to test the code by client level execution(Through a job) and once the code is working fine you can move it to the server call.

6. If you are creating a .Net instance in a class and wanted to retain the instance as a global variable then you must declare the variable as CLRObject and not in the actual .Net namespace name(Eg: Microsoft.Dynamics.Csharp). Failing to do so results in a run time marshalling error.

Running AIF without Active directory in Dynamics Ax

April 19, 2010 Leave a comment

It is necessary to ensure that the system is in a AD(Active Directory) before using AIF. But for developers/testers sometime they may want it to work even without the network & AD, Here is a article how to make small modifications to your AIF logic so that you can run it without network….