Iterating a container using BusinessConnector

I am call a function from C# using the business connector dll. I have no idea how to do this. I tried instantiating a container, but there is no constructor.

So, briefly, I am calling a function that returns an object (CallStaticClassMethod) and this object is a container. How do I convert and get the values within that container.

Any help appreciated.

If you have no idea how to do something, your first reaction should be to find and read the documentation. Nevertheless you should avoid using Business Connector, especially in AX 2012 which offers many better options. If you tell us what you’re trying to do, we might be able to show you how to do it without Business Connector.

If you decide to use Business Connector despite everything, realize that you don’t don’t need to instantiate the container if you already get it from the method. If you check the type of the object you receive, you’ll find that it’s AxaptaContainer. Use its method and properties to manipulate the container.

There is nothing in the Object explorer for the business connector. Nor is there any handy C#->AX programming documentation.

I am using AX 4 and calling a class function. I am unaware of another way to do this from within .Net than through the business connector.

I added the tag with your version of AX to your question (among other tags). Please do it by yourself next time.

The documentation for AX 4.0 is here - you can find it at any time by using your favorite search engine. Your other option would be using AIF, nevertheless I can’t say from the (lack of) description whether it would be a wise choice or not. Unfortunately you’ll miss best features for integration (e.g. custom services and proxy classes) until you upgrade to AX 2012.

I found some code to iterate a container, however, it seems i can;t get what is wrapped within the conainer

AxaptaContainer path = (AxaptaContainer)ax.CallStaticClassMethod(“DocumentHandling”, “ItemData”, “1000000”);

for (int i = 1; i < path.Count - 1; i++)


string somestring = path.get_Item(i).ToString();


Gives me “Microsoft.Dynamics.BusinessConnectorNet.AxaptaContainer”. This function is supposed to be returning strings containing paths to document handling objects

No, you’re wrong. The return type get_Item() is Object, not string, because you can use any value types in containers. You can see the type in the documentation.

If the type of your item(s) is AxaptaContainer, you have a nested container there. Unfortunately your code doesn’t support that - you should rewrite it to iterate through nested containers too, possibly by using a recursive method.