Skip to content
  • There are no suggestions because the search field is empty.

CSM Automations and Job Queues

CSM Automation Routines

CSM’s automation structure supports the definition of automation routines. These routines can be executed according to a defined schedule, allowing you to automate activities such as order retrieval and building of a sales order from the retrieved order information.

CSM includes a set of predefined automation routines that are automatically loaded as part of the setup process. To view these routines:

  • Choose the looking glass
  • Enter API Automation and choose the related link (Magento and Walmart)
    • CSM Automation List for legacy API Engine (Shopify, BigCommerce, WooCommerce and Amazon).  Please refer to Legacy CSM Automation List Information.

The API Automation page presents a separate line for each major area of automation that exists for the application. When an automation line is selected, the individual automation routines that comprise it are presented in the Steps FastTab midway down the screen. These routines are automatically loaded by CSM, but you can adjust the default values or create new routines if necessary.

The fields on the Steps FastTab are as follows: 

Field Description Example Value
Enabled Place a check mark in this field if you want to include the automation routine as part of the scheduled job queue execution that has been defined for the automation. You can leave this field unchecked if you do not want to use the automation routine or wish to manually execute it.   
Sequence The order in which automation routines are executed in relation to one another. Certain routines must be completed before others can begin. For example, order information needs to be retrieved from an external platform before it can be used to build sales orders in Business Central.  110
Code The unique code that identifies the automation routine. CSM is configured to use specific automation codes, and these should not be manually modified by you.  BUILD_SALESORDER_ PROCESS 
Description

A description of the automation routine.

Build retrieved acknowledged Sales Orders with processing channel status for e-commerce Platform 
Automation Type

The type of automation executed by the routine. 

API: automation routines that are run against an entire API set and are not associated to a specific sales channel that uses the API Set. This allows for more efficient API processing for certain activities. For example, actions to retrieve orders are typically defined as API routines; if you have multiple sales channels set up in Business Central, these routines will retrieve orders for all of them.
Order: automation routines that are concerned with processing CSM orders. When order information is retrieved into Business Central, it is maintained in a dedicated CSM Order table. Order automation routines can instruct CSM to use the data in this table to create Business Central sales orders. Order automation routines also exist for the retrieval of additional order information from an external sales channel to a CSM order.
Fulfillment: automation routines that are concerned with sending fulfillment information such as shipment, invoice, and credit details from Business Central to an external sales channel. Setup and configuration fields on the sales channel allow you to indicate the method by which this information is communicated, with one of these options allowing you to say you want to schedule this information to be sent when an automation routine is executed. If your sales channel is configured in this way, you must execute the relevant automation routine in order to send the information to the external platform.
Listing: automation routines that are concerned with sending and retrieving of CSM listing information between Business Central and the external sales channel. This can include routines for creating new products on the external platform from CSM listing information, sending inventory information from Business Central, and updating prices. 
Order
Scheduled Frequency

The frequency at which the routine will be executed as part of a given automation run.

1 Minute
Last Run Timestamp This field is automatically updated whenever the automation routine is successfully executed. CSM uses this value in conjunction with the automation routine’s scheduled frequency to determine whether or not to execute the routine the next time the automation runs. For example, if an automation routine’s last run timestamp was 10/01/24 12:00 PM and its scheduled frequency was 10 minutes, it would not be executed as part of a data retrieval process that was run at 12:05 PM on 10/01/24. It would, however, be included as part of a data retrieval process that was run at 12:10 PM or later.   
Parameter String When CSM automation job queues are run, they can be configured to execute automation routines that share a particular codeunit. By default, all CSM automation routines share the same parameter string, but you can modify this value if you want to run different groups of automation routines via separate job queues   
API Set Code The API set code that contains the underlying functionality that will execute the automation routine.  MAGENTO02
API Function Code If the automation routine sends or retrieves information between Business Central and the external platform, this field contains the API function that is used to perform the activity. This field will remain blank for automation routines that are not concerned with moving data between the two environments.   
CSM Properties

Indicates the number of unique CSM automation properties that exist for the automation routine. Choosing this number will present a separate page that displays these values.

CSM automation properties allow you to specify particular criteria that are required for a routine to be executed or instruct CSM on what sort of actions should be performed as part of the routine. For example, an automation routine could be configured to apply to only those CSM orders that have a particular order status. 
 
Update Last Run Timestamp on Error Place a check mark in this field if you want to update the automation routine’s last run timestamp if it fails to properly execute. By default, the automation routine’s last run timestamp will only be updated if the routine is successfully executed, but you can use this field to update this value whenever the routine is run, regardless of the result.   

CSM includes two out-of-the box automation codeunits. These codeunits are configured to execute against a particular automation code. When a codeunit is run, any CSM automation routines that share the relevant automation code will be executed. The out-of-the-box codeunits are configured to execute against default codeunit ID code values:

Automation Routine Type Codeunit Automation Code
Order Management 70338249 ORDER_MANAGEMENT
Listing Management 70338246 LISTING_MANAGEMENT

Using the above table to illustrate, running codeunit 70338249 will by default execute any automation routines that are assigned to the automation code ORDER_MANAGEMENT.

It is possible to assign parameter strings to specific automation routines, then set up separate job queue entries for each string. In this way, you can configure the execution of automation routines to occur according to different schedules. This is typically not necessary, but there are some scenarios such as high-volume environments where scheduling different groups of automation routines to run separately can improve performance.

The order in which automation routines are executed is determined by their assigned sequence values.

Housekeeping Automation

In addition to the automation routines that exist for specific eCommerce activities such as order retrieval, sales order creation, and sending of shipment/invoicing information, CSM includes a “housekeeping” automation. This is a channel and platform agnostic routine that performs maintenance activities:

  • Deletion of API messages and their related data buffers according to the API message retention period defined on the CSM Setup
  • Archiving of CSM orders according to the archiving settings that are defined for each sales channel.
Note: Suite Engine has made CSM tables available for inclusion as part of Business Central’s standard retention policy functionality for the deletion of outdated data. While the housekeeping automation is still necessary for the archiving of CSM orders, we recommend that you use retention policies for the purposes of data deletion. The below remaining content in this section should only be read for assistance in configuring the housekeeping automation for the purpose of CSM order archiving.

It is recommended that you schedule the housekeeping automation to occur at a time of low activity. For example, scheduling the routine to run overnight, outside of working hours, helps to ensure that it can perform its functions without impacting user activity.

It is strongly recommended that you ensure the housekeeping automation is executed on a regular basis. Failure to run this automation will result in the related tables growing to an excessive size, until eventually it becomes necessary to purchase additional storage space to maintain them.

The standard manner in which the housekeeping automation operates is to identify all records that require deletion/archiving, then commit this deletion/archiving as a single activity. While this is the most efficient way to perform the process, it is important to note that interruptions to the housekeeping when it is running will roll back whatever progress has been made up until that point. For example, consider a scenario where a large volume of records require deletion, and the housekeeping automation runs for five hours as it identifies these records. A sudden interruption or abortion of that process will have effectively undone the previous five hours’ worth of work.

In scenarios where the housekeeping automation is executed on a regular basis and the volume of records it processes is manageable, the issue described above is not a concern, since the routine should finish within a reasonable timeframe. However, in situations where the volume of records has grown to an excessive amount, the standard behavior of the housekeeping automation makes it difficult if not impossible to clean up this data. In such a scenario, it is possible to modify the standard behavior of the housekeeping automation by making an entry in the Maximum Run Time field.

When this field is left blank, the housekeeping automation will run for as long as it needs to in order to address all relevant records. If this field is populated with a duration, however, the housekeeping automation will run for as long as that specified duration, with each record it encounters being immediately deleted/archived, rather than at the end of the process. In this way, it will take longer to clean up data, but there is no danger of this cleanup being undone or rolled back.

To illustrate how this setting impacts behavior, consider the following scenario. Suppose we have defined a 60 day API message retention period, and we have 30,000 API messages older than 60 days in our database. In this scenario, the housekeeping automation is able to delete 100 messages every minute.

    • If we leave the Maximum Run Time field blank and execute the housekeeping automation, it will attempt to delete all 30,000 API messages. At 100 messages a minute, it will take 6 hours for this process to finish. The benefit of this process is that if it is able to successfully finish, all relevant records will have been deleted. However, the potential downside is that any disruption will cause all changes up to that point to be rolled back, meaning that all 30,000 API messages will still be present in our database.
    • Suppose we instead enter a value of 1 hour in the Maximum Run Time When we execute the housekeeping automation, it will run for 1 hour. At 100 messages a minute, it will delete at most 6,000 messages. Because it deletes messages one by one, rather than as a single action, any disruptions to the process will not roll back progress up to that point. So if for some reason the housekeeping runs for 10 minutes out of the scheduled hour and is interrupted, the 1,000 API messages it has already run through will remain deleted. The benefit here is that we are definitively able to delete records, with the disadvantage being that it will take more time to fully clean up the data.

Essentially, assigning a maximum run time to the housekeeping automation sacrifices efficiency in favor of slower but guaranteed results.

As stated above, in environments where the housekeeping automation is executed on a regular basis and the volume of records it needs to address at any given time is manageable, the default behavior is preferable. Defining a maximum run time should only occur when the housekeeping automation is unable to finish normally, and it becomes necessary to incrementally reduce the volume of records. In such a scenario, once the volume of records is sufficiently decreased, it is recommended that you remove the maximum run time value and allow the housekeeping automation to resume operating according to its standard behavior.


Configuring Job Queue Entries

While the process of manually running CSM’s automation routines is useful in testing or troubleshooting scenarios, it is not the intended way in which the application should be used. Once you have tested CSM and validated that the automation routines work as desired, you can schedule them to occur on a recurring basis by using standard Business Central job queue functionality. CSM includes the following codeunits that can be assigned to job queue entries:

  • 70338249, CSM SENAPI Order Management
  • 70338246, CSMSENAPIListingMgmtAutomation

By default, the CSM job queue entry codeunits will execute against all enabled automations for a given automation. For example, the order management codeunit will by default execute against all automation routines in the ORDER_MANAGEMENT automation. However, you can manually add a parameter string to an automation routine, then set up a separate job queue entry with a parameter string filter for this new value. When this job queue entry runs, it will execute only those automation routines that share this parameter.

A common scenario in which this is useful is in high-volume, multi-channel environments. If a single job queue entry is responsible for retrieving orders for all channels, the large volume of records being processed may lead to performance issues. In addition, if a problem with the order retrieval process exists for one channel, this failure will prevent the retrieval of orders for all other channels. In such a situation, you could assign different parameter strings to the automation routines for each channel, then set up separate job queue entries, each with a different parameter. In this way, each job queue would execute the automation routines for a separate sales channel, reducing the overall volume of records being processed as part of each activity.

Note: the buttons on the CSM Administrator Role Center that allow for the execution of order management and listing management automation are hard-coded to the default automation codes. If you create additional automation routines with different parameter strings, they will not be included as part of these Role Center actions.

To create a job queue entry for order management automation:

  • Choose the icon, enter Job Queue Entries, and then choose the related link.
  • Choose the New action in the ribbon to create a new job queue entry.
  • In the Object Type to Run field, select the Codeunit
  • In the Object ID to Run field, enter 70338249.
    • If you have assigned different parameter strings to your automation routines, enter the one for which you are setting up the job queue entry in the Parameter String
  • To define the frequency with which the job queue entry will run and other setup values, please follow standard Business Central practices.
  • If you are working with multiple parameter strings, repeat steps 1-6 to set up additional job queue entries for each one.