Assigning a task to be performed as a batch task

This process would be a common process for your users. This allows users to submit long-running tasks to the server, allowing them to continue using AX while the server processes the task. This is often underused, leaving users to watch an unresponsive screen while they wait for complex routines to finish (for example, a set of delivery notes to be printed).

Getting ready

Most users will be able to submit jobs as batch tasks. This example submits a Master plan schedule to be run as a batch task, so we will require appropriate privileges. The process is similar for most tasks that utilize the batch framework.

How to do it...

We proceed as follows:

  1. Navigate to Master planning | Periodic | Master Scheduling.
  2. Select a master plan as required (for the purpose of this exercise, any will suffice).
  3. Click on the Select button and use the query dialog to filter on an item or item group; this is merely to show that this information is stored against the batch task.
  4. Select the Comment tab and enter a comment in the Comment textbox, for example, Master plan for procured items.
  5. Select the Batch tab.
  6. Check Batch processing and select an appropriate Batch group.
  7. The task description appears against the item in the batch queue, so you may change this if you want to easily identify it later. However, this is normally left as default.

    Note

    Ignore the private checkbox as this applies only to client tasks and is considered a "legacy" feature.

  8. Click on Recurrence.

    Note

    The default options here are to start as soon as possible and run only once.

  9. Adjust the start date and time if required.
  10. Change the option for No end date, End After, or End by. The default is End after 1.
  11. If this is a recurring task, you should review the Recurring pattern (which is straightforward).

    Note

    If this is a recurring task that you wish to run frequently (for example, monitoring a folder to import files), don't set this to every minute without considering if this is actually necessary as this may add unnecessary load to the server.

  12. Click on OK on the Recurrence dialog.
  13. Click on Alerts.
  14. You have the options to limit what you are alerted about and whether or not you should be alerted. If this is a task that runs frequently, you will almost certainly not want Ended alerts (which would send an alert every time the job is executed successfully).

    Note

    The Batch processing setting is remembered and becomes default when the next task is run. If the users want to run the task interactively, they will need to clear this checkbox.

How it works...

Many of the tasks you can perform interactively have a Batch tab that allows you to submit the task as a batch job. When the task is submitted, it is written to the batch queue with the following information:

  • The task to be performed
  • The batch group in which the job should be processed (remember, "blank" is also a valid batch group)
  • Alert setting information
  • The information entered into the dialog; the query and other parameters that were entered when the task was submitted
  • Recurrence information

The batch server(s) will select the jobs to process based on the following:

  • Does the batch group on the batch task fall within its list of batch groups?
  • The time it should start, which is more accurately called "Do not start before"
  • The status is Waiting

The batch server will rehydrate (unpacked from the batch job record's packed data container) the task and execute it under the security context of the user who submitted it, with the options the user specified.

Should the task succeed, the status will be updated to Ended and an alert will be sent to the user (if this was configured). If the job failed, the status will be changed to Error and an alert will be sent to the user (again, only if configured). In both the cases, the infolog (message) that was created by the task will be stored against the task, allowing the user or administrator to investigate any errors.

You can go to an item in the batch queue anytime before it starts executing to view and change the information on the initial dialog, alert request, or the recurrence information. You should first change the status to Waiting, as you will not be able to save the changes if the job starts in the mean time.

There's more...

You can also create batch jobs directly in the queue. For instance, the AIF-processing jobs are configured in this way.

The following example is to add the AIF tasks to a batch job:

  1. Navigate to System administration | Inquiries | Batch jobs.
  2. Click on New (Ctrl + N or File | New).
  3. Enter the description AIF Processing.

    Note

    The start time will be set to now, which is fine in this case; this can be made to be the initial start time (for example, 02:00 tomorrow for nightly jobs).

  4. Click on View tasks.
  5. In the batch tasks form, click on New (Ctrl + N, or File | New).
  6. In the task's description, enter AIF Receive.
  7. Select or enter AifGatewayReceiveService for the class name.
  8. Select an appropriate batch group, for example, Sys-AIF.
  9. Press the down arrow (or Ctrl + N) to create additional tasks for the following, in the order stated:
    • AifInboundProcessingService
    • AifOutboundProcessingService
    • AifGatewaySendService
  10. To set conditions for the task so that they only run based on the result of the previous task, click in the lower grid and press Ctrl + N, as shown in the following screenshot:
    There's more...
  11. Once complete, close the form, which brings us back to the batch job form.
  12. You can now decide to enable alerts and set the recurrence as before.
  13. Finally, click on Functions | Change status to move the status from Withhold to Waiting; this enables the batch job.

Query functions

You can also use functions to generate relative dates; these are not documented formally, but the code is well-documented and easily read by a developer.

A developer can even extend them to provide more functions to the user.

These are the static methods on the class SysQueryRangeUtil.

The common methods are:

Function

Example usage in a query range criteria

currentDate

(currentDate())

currentLegalEntity

(currentLegalEntity())

currentUserId

(currentUserId())

day

(day(10)) current date plus 10 days

dayRange

(dayRange(1, 5)) date range of today plus 1 and today plus 5

greaterThanDate

(greaterThanDate(-5)) records where the date is greater than the current minus 5 days

greaterThanUtcDate

(greaterThanUtcDate(1)) for UTC dates, records from tomorrow

greaterThanUtcNow

(greaterThanUtcNow()) for UTC dates, records from now

lessThanDate

(lessThanDate(-90)) records older than 90 days

lessThanUtcDate

(lessThanUtcDate(-90)) for UTC dates

lessThanUtcNow

(lessThanUtcNow()) for UTC dates, record before now

monthRange

(monthRange(1, 2)) records from the start of the next month to for 2 months

yearRange

(yearRange(0, 1)) records in this year

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.79.84