Skip to Content

Use Scripts to Chain or Control Operations

Introduction

Scripts written in Jitterbit Script language or JavaScript can be used almost anywhere in operations and within transformation mappings.

Operation Chains

Operations can be organized into operation chains in two ways: (1) by linking operations using On Success and On Fail conditions using operation actions or (2) by using a controller script.

Instead of using operation actions, a controller script uses the RunOperation function to link operations together using a script.

To capture a failed operation, the If function can be used in conjunction with RunOperation. For example: If(!RunOperation(<operation tag>),<condition>), where the condition can use GetLastError to capture the error, and can elect to stop the entire process using RaiseError, and/or run another process to accumulate error text.

Controller Scripts

A controller script can be beneficial in situations such as these:

  • To run an operation that is dependent on external factors such as project variables or data.
  • To call sub-operations from within a loop, where data is passed to the operation from a list.
  • To trace operation chain activities. For example: (WriteToOperationLog("count of records to process: " + cnt), WriteToOperationLog("Starting update operation at: " + Now()), WriteToOperationLog("Database query: " + sql), etc.)

Other Uses of Scripts

Other areas where scripting is frequently used are within the mapped fields in transformations and in other stand-alone scripts. If the same script is being used within more than one transformation, consider setting up that script as a stand-alone script and calling it from within each transformation using RunScript.