Search This Blog

26 June 2011

Batchable AxdSend-class in Ax2009 and Ax2012

The AxdSend-class is a very easy to implement class, that helps you writing outbound services for Dynamics Ax 2009 and 2012. The AxdSendExchangeRates-class from Ax 2009 (not existing in Ax 2012 anymore) gives you an idea of how to use this class. Unfortunately there are some reasons why the AxdSend-class cannot run as-is in batches:

  1. The base class: The AxdSend-class needs to derive from RunBaseBatch.
  2. The dialog: The dialog is built on the axdSend-form which does not provide the 'tab'-control for the RunBaseBatch-dialog. This form needs to be modified by adding a new tab-control named 'tab'. Otherwise you would get an exception from the buildControl-method in the DialogForm-class. Btw: The name 'tab' is hardcoded in the tabName-method of the same class.
  3. The method sendMultipleDocuments: calling this method results in calling the run-method, and, as you know, batches are executed by calling the run-method...
Changing this would let the AxdSend-class be 'batchable', but unfortunately the class wouldn't be executable in the interactive mode anymore. This, because the dialog form from the AxdSend, which is opened by calling the prompt-method, requires these members being initialized:
  • aifDocumentClassId
  • serviceClassId
  • aifConstraintList
  • aifSendMode
  • sendActionType
  • aifActionId
My suggestion here is to create a new base-class for batchable AxdSend-classes to isolate these modifications as much as possible. You can download a private project  that contains my modifications/new classes for Ax2009 in all concerned AOT-objects:
  • AxdSend-class
  • axdSend-form
  • AxdBatchableSend-class (custom base-class)
  • AxdSendExchangeRates as an example how to use the AxdBatchableSend class
The batch will use the endpoint that is stored in the usage-data. So the batch needs to be executed at least once in the interactive mode.
Important note:
Importing this project will overwrite these objects and overwrite all modifications in the same layer, too. Please be careful when importing the project.
These modifications are not compatible with Ax2012, but it requires only slight changes to adapt this to Ax2012. I will upload a project for Ax2012 once Ax2012 is released.

Update: (30/06/11) I fixed an issue with the initialization of the endpoint-list.
Update: (02/07/11) Ups, fixed an issue with the dialog initialization.
Update: (04/07/11) Sends only message if query returns more than one element.

4 comments:

  1. Hi Florian,
    I've downloaded your xpo and installed it on our Ax 2009. When I tested the modified AxdSendExchangeRate it didn't work very well. There was not any batch tab and when I clicked the cancel button I got the following error:
    "The object does not have the method batchinfo"
    The stack says it is in
    RunBaseBatch.prompt line 4 (if (dialogCaneceled && this.batchinfo())

    /Lars

    ReplyDelete
  2. Hi Lars,
    The reason why it didn't work is that the Xpo didn't contain the AxdSend-Form. I did this, because I didn't want to change too much standard-object since I described the modification in the article.
    I just uploaded a new Xpo on SkyDrive which includes this from. But please do a backup of this object if this has already been customized...
    Kind regards,
    Florian

    ReplyDelete
  3. Hi Florian,

    thank you for a comprehensive example. However, when running AxdSendExchangeRates and want to narrow the output down by specifying query values in the dialog (i.e currency code 'EUR') I still get all exchange rates - it does not seem as if the values are taken into account when the service is run. Is there some additional modification to the class needed?

    /Jake

    ReplyDelete
  4. Do you have an AX2012 version (using SysOperations Framework)?

    ReplyDelete