Creating Custom Job Steps
If there is no system step that does what you need to do, a developer must develop a custom job step. The developer first writes a task-oriented or chunk-oriented CommonJS script module or a legacy pipeline to describe what the step does. The developer includes the module or pipeline in a cartridge along with a JSON or XML file that describes the step, and then uploads the cartridge to the site. The custom steps are then available to the administrator creating jobs. The topics in this section are for developers.
- Task-Oriented Script Module
You can define what a custom step does using a task-oriented CommonJS script module that exposes a function to be called as the main function for the job step. When administrators create jobs using Business Manager, they set parameters that are available as scriptable objects for the module's function and for thedw.job.JobStepExecution
object. Thedw.job.JobStepExecution
object allows read-only access to information about the current step execution and job execution. - Chunk-Oriented Script Module
You can define what a custom step does using a chunk-oriented CommonJS script module that reads and processes items in chunks of size S. If the list contains more items than can be processed in one chunk, a new chunk is started. A chunk-oriented script can include any series of processing steps, not just database transactions. A job step that uses a chunk-oriented script allows fine-grained progress monitoring because the number of elements that are written is updated each time a chunk is finished. - Job Step Exit Status
In a task-oriented script module or pipeline for a custom job step, you can create an object of typedw.system.Status
to control the exit status and error message for the step. TheStatus
object includes a boolean flag that indicates whether or not the status is error, and also a status code and message. Messages appear in Business Manager and are written to log files. You can't define the exit status for a chunk-oriented script module. Chunk modules always finish with either OK or ERROR. - Steptypes.json Syntax
The steptypes.json file, which describes custom job steps, requires a specific JSON syntax. If a steptypes.json file contains errors, the errors are logged and the steps are not registered. The system then loads steps from thesteptypes.json
files of other cartridges. A typical error message for an invalid steptypes.json file isInvalid step [Step1]! Type with id [custom.MyCustomStep1] is unknown!
. - Steptypes.json Example
This example shows a steptypes.json file that describes three custom steps: a step defined using a task-oriented CommonJS module, a step defined using a legacy pipeline, and a step defined using a chunk-oriented CommonJS module. - Steptypes.xml Example
You can use an XML definition instead of JSON to define your custom steps. The file must be namedsteptypes.xml
and placed in a custom cartridge in the root folder. The XML file is parsed and reloaded whenever the active code version is changed. You can only have one steptypes.json or steptypes.xml file per cartridge. - Steptypes Schema File
Use thesteptypes.schema.json
file to check the syntax of yoursteptypes.json
file. - Create a Custom Job Step
To create a custom job step, you must develop a task-oriented or chunk-oriented CommonJS script module or legacy pipeline to define what the step does. You must also create a JSON or XML steptypes file that describes the step, and then include the module or pipeline along with the steptypes file in a cartridge uploaded to the site.
Infocenter Retirement: On June 30, 2023, the Infocenter was retired, and documentation currently hosted on the Infocenter will be published to Salesforce Help, Commerce Cloud Developer Center, and Salesforce B2C Commerce Developer Documentation Resources. For more information, see the release note.