Config / Automation / ANVEDI Job Handler

ANVEDI Job Handler

Microsoft Dynamics 365 Business Central has a job scheduling system that allows you to run codeunits at certain times. Anveo EDI Connect offers a dedicated codeunit that can be used. The codeunit has the ID 5327312 and is called ANVEDI Job Handler.

Example Job Queue Setup in Microsoft Dynamics 365 Business Central

This codeunit offers different jobs and can be controlled by the parameter string. This string follows simple rules and we will show you examples for each of the available actions. The general syntax of this parameter is:

ACTION_NAME(Parameter1=Value1, Parameter2=Value2)

There are two parameters that are available for most jobs, except for Business Transactions:

ProcessFollowing

Controls whether post-processings are executed automatically. This defaults to False, if not specified.

True

The post-processing should run afterwards

False

The default setup will determine if post-processings will run.

ProcessQueueView

This parameter is optional. The default value is no table view. This parameter specifies a view on the table for the EDI Processing Queue that is used if ProcessFollowing=True. The string has to be a Microsoft Dynamics 365 Business Central table view, like WHERE(Project Code=FILTER(A*)).

Frequently Used Actions

Most of the times, you will want to use one of the following actions:

Receiving data

This action will receive data for a specified communication channel or folder.

RECEIVE(Channel=MY_COMM_CHANNEL, ProcessFollowing=True)
Example Parameter String: Receive data from communication channel MY_COMM_CHANNEL

You will have to specify one of the following parameters:

Channel

Specifies a filter string to the communication channel code. This can either be the full code, or a filter string.

Folder

Specifies a filter string to the transmission folder code. This can either be the full code, or a filter string.

Run a mapping

Often times, if you want to export data you either start with a business transaction job, or a NAV mapping. But the scheduling system can run any kind of mapping.

RUN(ProjectFilter=TEST, FormatFilter=NAV, CodeFilter=EXPORT_JOB, ProcessFollowing=True)
Example Parameter String: Run the mapping TEST, NAV, EXPORT_JOB.
RUN(ProjectFilter=TEST, FormatFilter=NAV, CodeFilter=*, MultipleAllowed=True, ProcessFollowing=True)
Example Parameter String: Run all NAV mappings of project TEST.

The allowed parameters are:

ProjectFilter

The project code or a filter string on the project code.

FormatFilter

The format code or a filter string on the format code.

CodeFilter

The mapping code or a filter string on the mapping code.

MultipleAllowed

Safety feature. Whether multiple mappings should be executed. Defaults to False.

True

Multiple mappings can be executed.

False

Multiple mappings cannot be executed.

Collect Business Transaction Data

If you have a business transaction type with data collection, you can use the following parameter string:

BT_COLLECT(Code=MY_BT_TYPE)
Example Parameter String: Collect the data like defined in the Business Transaction Type MY_BT_TYPE.

There is only one parameter:

Code

The code of the business transaction type. This parameter does not allow filters.

Maintenance

If you want to use the automatic retry functionality of the mappings or communication channels you have to setup a simple maintenance job. This job is really fast is there is nothing to do and can run quite frequently. Please consider that the job has to run at least as often as you want to retry actions.

MAINTENANCE()
Example Parameter String: Run automatic processes like retries.

The job has no parameters.

Advanced Actions

The following actions are more specialized and are not used that frequently.

Batch Process Business Transaction Data

BT_BATCH(Batch=MY_BATCH_CODE)
Example Parameter String: Run the batch action with code MY_BATCH_CODE.
Batch

The code of the Batch. This parameter does not allow filters.

Collect and Batch Process Business Transaction Data

This is a combination of BT_COLLECT and BT_BATCH.

BT_COLLECT_BATCH(Code=MY_BT_TYPE, Batch=MY_BATCH_CODE)
Example Parameter String: Collect data from MY_BT_TYPE and run the batch action with code MY_BATCH_CODE.
Batch

The code of the Batch. This parameter does not allow filters.

Code

The code of the business transaction type. This parameter does not allow filters.

Process Open Processing Queues

If you do not run post-processings automatically you can setup jobs to run certain open actions.

PROCESS(ProcessQueueView=WHERE(Project Code=FILTER(MY_PROJECT)))
Example Parameter String: Process open entries from project MY_PROJECT.

You can use the parameters ProcessQueueView and ProcessFollowing.

Send Open Transmissions

Usually sending data is done as a post-step of the mapping execution. If you want however to send open files at a certain time, you can use a job.

SEND(Channel=MY_CHANNEL)
Example Parameter String: Send the open transmission of MY_CHANNEL.
Channel

Specifies a filter string to the communication channel code. This can either be the full code, or a filter string.

Folder

Specifies a filter string to the transmission folder code. This can either be the full code, or a filter string.

Run Custom Code Callback

You can use the job handler codeunit to run your custom code.

You can specify as many parameters as you need. We recommend using a parameter Name to specify a callback identifier. You can access the parameters from the ANVEDI Callback codeunit. In codeunit ANVEDI Callback in the function CallbackRegistration you can react to the OnJobCallback event by implementing the following CASE block:

CallbackSupport.OnJobCallback(ParameterDictionary):
  BEGIN
    IF NOT ParameterDictionary.GETBYKEY('NAME', Tmp) THEN
      ERROR(Text001);

    Name := Tmp;
    CASE UPPERCASE(Name) OF
      'Example':
        BEGIN
          IF NOT ParameterDictionary.GETBYKEY('MYPARAM1', Tmp) THEN
            ERROR(Text001);
         MyParam1 := tmp;

         IF NOT ParameterDictionary.GETBYKEY('MYPARAM2', Tmp) THEN
           ERROR(Text001);
         MyParam2 := tmp;

        // Do something with the parameters MyParam1 and MyParam2
     END;
  ELSE
    ERROR(Text002, Name);
  END;
END;
Example Code in ANVEDI Callback Codeunit.

Please note that the parameter names are converted to uppercase in the variable ParameterDictionary. You can use the following parameter string in the Job Queue to call the callback:

CALLBACK(Name=Example, MyParam1=Hello, MyParam2=World)
Example Parameter String: Call custom code