Dealing with lists in .Net Business Connector and how to get around it

11. July 2009

So I had the pleasure of having to deal with Lists and Containers in the .Net Business Connector and it was NOT a pleasurable experience. Axapta uses lists and containers and trying to use them in C# was a complete nightmare because using either type always generated a ‘Bad Container’ error.

The Axapta SDK states that a List is equivalent  to a generic list in C#….this is incorrect Axapta doesn’t support generics. The real c# array to use is the ArrayList because it is not of generic type. When you go to pass the ArrayList into the method you must use the following code to do so: list.ToArray(typeof(string)). Otherwise you will get an invalid parameter exception but this still generated a ‘Bad Container’ exception.

The Axapta SDK states that you can use a AxaptaContainer to pass into a method where the container object is being used but unfortunately COM interop doesn’t translate it correctly and once again throws a ‘Bad Container’ exception.

The solution? I ended up using a comma separated  string to pass into a new method and used the Axapta ‘strSplit’ Global method to split the string into an Axapta List.

Below is the x++ method that I created

server static void finishMultiMDSi(str _pickListIds)
{
    List list = new List(Types::String);
    ;
    if (_pickListIds)
    {
        // We pass in a comma sep string, we split the string into a list
        list = strSplit(_pickListIds, ',');
        // Pass the list into the finishMulti method to post the pick list
        WMSPickingRoute::finishMulti(list.pack());
    }
}

Microsoft Axapta 2009

Executing Pick List Registration in code

11. July 2009

So I needed to post the pick list registration outside of Axapta. After quite a bit of time I found out exactly where it is done and it’s very simple.

WMSPickingRoute::finishMulti() is the method that is used to post the pick list registration and all the method takes is a container of PickingRouteId’s. You simply pass in all the PickingRouteId’s that you need to be Registered and the logic in this method takes care of it.

Microsoft Axapta 2009

New Blog

10. July 2009

After using Community Server for a number of years I decided to switch to a new blog called BlogEngine.Net. The reason I got away from CS is that they no longer provide a Personal Edition which I find strange considering the history of the product. Any way...Enjoy!

General