Christopher Kane

Ramblings of a Software Architect

Recent posts

Tags

Categories

Navigation

Pages

Archive

Blogroll

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

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

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());
    }
}

Posted: Jul 11 2009, 02:10 by ckane | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading