-->
There are tons of blog posts available on the internet guiding to use business connector for read/write operations. Most of them are dealing with how to write opening a table buffer, initializing it, setting field values (set_Field()) and then hitting the write operation.

This is good and simple, and so is sending parameters to table / class, but I could not find the later under any relevant title, hence getting the exactly required thing difficult.

I found my need fulfilled somewhere in Mr. Corey Lasley's blog post: Using the .NET Business Connector to Export...

So the topic actually is about reusing existing business logic. And in doing so, you will need to call several existing, well defined, well tested Class / Table methods. And in doing so.... :D you may need to call paramater less and parameter requiring static methods.

There are two methods inside the 'Axapta' class, 'CallStaticClassMethod' and 'CallStaticRecordMethod'. Both of them calls static methods from Class objects and Table objects respectively. The below code (.Net --> C#) excerpt provides a tutorial for calling an existing existing table method and passing parameters to it.

Axapta ax;
            AxaptaRecord objAxRec;
            Object[] parm = new Object[2]; 
            Object result;
            parm[0] = "Param1Value";
            parm[1] = "Param1Value";

            try
            { 
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                result = ax.CallStaticRecordMethod("InventSum", "find", parm);                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
As you can see, an array of objects (size of method's parameter count) is assigned values and passed it as the last parameter.

For classes, use 'CallStaticClassMethod'

0 comments:

Post a Comment

top