In standard Connectivity Studio, you can run a message in two ways:
On the client: If you run a message on the client, you must wait till the message is finished before you can continue working on the client.
In batch: If you run a message in batch, it usually takes some time till the batch is started and till it is finished.
To address the downside of both cases, you can run a message asynchronously. As a result, the message runs directly in a separate background process. So, you can continue working on the client when the message runs. Running a message asynchronous is only useful for messages that are not run in batch. For example, when you run a message from an action menu item or from custom code.
BisRunMessageAsync
To run a message directly, custom code is required that calls 'BisRunMessageAsync' class. This class has two methods. Which of these methods you apply, depends on your scenario:
Method | Argument | Explanation |
|---|---|---|
startMessageAsync |
| Starts a message directly in a separate background process. |
| messageRecid | The RecId of the message to be run. |
BisArgs | The arguments for the message. For example, to set the record. | |
showMessage (default=true) | Shows the info messages as created by the message run. | |
startMessageQueueAsync |
| Starts the outbound queue directly in a separate background process. The outbound queue is started for a specific record only.
|
| eventlogRecid | The RecId of the outbound queue record to be run. |
showMessage (default=true) | Shows the info messages as created by the outbound queue run. |
Example
As an example, for EDI, you must start the outbound queue when a sales invoice is printed. The outbound queue must be started only for the records that are related to the printed sales invoice. In this case, you can use the 'SalesInvoiceJournalPrint' class. This class handles the printing during the posting process. In this class, use the method ‘printJournal’ which allows you to create a new static class with this static method:
[PreHandlerFor(classStr(SalesInvoiceJournalPrint), methodStr(SalesInvoiceJournalPrint, printJournal))]
public static void SalesInvoiceJournalPrint_Pre_printJournal(XppPrePostArgs args)
{
int test = 1;
Set journalList = Args.getArg('_journalList');
SetEnumerator se = journalList.getEnumerator();
while (se.moveNext())
{
Common journal = se.current();
BisMessageTableEventLog eventlog;
while select firstonly eventlog
where eventlog.eventTableId == journal.tableId
&& eventlog.eventRecid == journal.recid
&& eventlog.eventStatus ==BisTableEventStatus::New
{
BisRunMessageASync::startMessageQueueAsync(eventlog.RecId, false);
}
}
}Note
This example only works if, on the Posting invoice dialog, the Print invoice field is set to 'Yes'.