You can run a message from code. You can do so to export or import data. For example, you can run a message to:
  • Import data: If you want to select a file from a local folder, copy it to your work folder, and process the message to import the data from the file.
  • Export data: If you want to export sales orders that get a specific status. For example, all sales orders that get the status Delivered, are exported.

Create custom code

To run a message from code, some code customizations are required. As no changes to standard code are allowed, you can:
  • Extend the desired standard D365 FO class or table, if supported.
  • Create a new class.
The custom class must be run at a point where you want to run the message. Use this custom class to call and run the message. For example, you can extend the post packing slip code, to run a message when the sales order gets the status Delivered.
In the custom class, add code to:
  1. Find the message. For example:
    BisConMessageTable myMessage = BisConMessageTable::FindRecid(MyMessageReicd);
  2. Create the message arguments. For example:
    BisArgs myArgs = new BisArgs();
  3. Adjust arguments. For example, to add the current record:
    myArgs.record(currentRecord); (this is, in the example, the Delivered sales order record)
  4. Optionally, add dialog arguments to define the range. For example:
    BisDialogBase myDialog = new BisDialogBase();
    myDialog.setFieldValue("company", curext());
    myArgs.dialogBase(myDialog);
    Note: Make sure, to add the dialog argument as parameter to the applicable document record range.
  5. Run the message. This code processes the message with the defined arguments. For example:
    myMessage.run(myArgs);

See also

Provide feedback