Skip to end of metadata
Go to start of metadata

Introduction

Scripts can be used in multiple places within a project, including within the design canvas as steps of an operation, as well as within transformations to apply specified logic or conditions to the data. The steps to create a script and perform further actions on a script are different depending on the type of script, as covered on this page.

Script Types

There are three distinct types of scripts that differ in how they are created and used within a project:

  • Script as a project component 
    This type of script can be used as a step in an operation and/or called using the RunScript function. This type of script appears as a project component within the script component palette as well as within the project pane. The script language can be either Jitterbit Script or JavaScript.
  • Script on a target field in a transformation 
    This type of script can be created on a field in a transformation to apply the specified logic to the transformation mapping. The last value returned in the script is used as the value for the target field. This type of script is available only on target fields in a transformation mapping. The script language must be Jitterbit Script.
  • Condition script on a target node in a transformation 
    This type of script can be applied on a node in a transformation in order to determine if the source record being processed should be output to the target. If the script evaluates to true, then the record is output. If the script result evaluates to false, then the record is skipped. This type of script is available only on target nodes in a transformation mapping. The script language must be Jitterbit Script.
NOTE: The script language used within transformations is limited to Jitterbit Script. Scripts used within operations can use either Jitterbit Script or JavaScript.

Script as a Project Component

This type of script is a project component that can be used as a step in an operation or called by another script using the RunScript function. As an example, you could use a script as a step in an operation before or after an activity to retrieve data and then process script logic, or you could run a validation script before proceeding to a transformation.

Creating a Script

A new script as a project component can be created from these locations:

New scripts are created with the default name New Script. Subsequent new transformations with default names are appended with an incremented number in parentheses.

On creating a new script, the script editor opens for you to configure the script (see Script Editor).

Script Actions Menu

After a script as a project component is created, menu actions for that script are accessible from these locations:

Each of these menu actions is available:

  • View/Edit: Opens the script editor for you to build the script (see Script Editor).
  • Cut: Places a copy of the script on your clipboard and deletes the original script from the project (see Component Reuse).
  • Copy: Places a copy of the script on your clipboard (see Component Reuse).
  • Duplicate: Creates a new, unreferenced script using the same configuration as the original script (see Component Reuse).
  • Deploy: Shows these menu actions:
    • Deploy: Deploys the script and any components it is dependent on (see Component Deployment).
    • Configurable Deploy: Opens the deployment screen, where you can select components to deploy (see Component Deployment).
  • Rename: Positions the cursor on the script name for you to make any edits as necessary.
  • View Dependencies: Changes the view in the project pane to display any other parts of the project that the script is dependent on (see Component Dependencies, Deletion, and Removal).
  • Add to Group: Opens a dialog to create a new custom group or to add the script to an existing group (see Component Groups).
  • Delete: Permanently deletes the script (see Component Dependencies, Deletion, and Removal).
  • Remove: Removes references to the script as an operation step on the design canvas (see Component Dependencies, Deletion, and Removal).

Script on a Target Field in a Transformation

This type of script can be added on a field in a transformation in order to apply the specified logic to the transformation mapping. The last value returned in the script is used as the value for the target field. As an example, you could use scripting to change field data from a string to an integer, concatenate values, or use a database lookup for a field.

Creating a new script on a target field is done during transformation mapping in either mapping mode or script mode and is limited to Jitterbit Script language.

To add a new script on a target field, either double-click the field name, or hover over the target field and click the add icon  in the top right of a target field to open a menu of actions. From the menu, select Add Script:

To edit a script on a target field that already has a mapping, either double-click the field name, or click the script icon  in the top right of a target field.

These open the editable script area on the target field in script mode, where you can enter or edit the script logic for the mapping:

To view the full script editor with all available options for the script, click the popout icon  in the upper right. For details, see Script Editor. After opening the full script editor, click the return icon  to come back to this screen.

To remove the script, simply delete the text of the script. For more information on this type of script, see Mapping with Scripts.

Condition Script on a Target Node in a Transformation

A condition script is created on a target node in a transformation to determine if the source record being processed should be output to the target based on a defined condition. The condition determines (yes or no) if the record is mapped. As part of that determination, you can include logic to set what values are used in the mapping. For example, a record might only be used if the size of a text field is less than a specified maximum.

Creating a new script on a target node is done during transformation mapping in either mapping mode or script mode and is limited to Jitterbit Script language. Conditions can be added as scripts on target nodes in any level of a data structure.

To add a new script on a target node, hover over the node name and click the actions menu icon  to open the actions menu. From the menu, select Add Condition to Node:

This opens the editable script area on the target node in script mode, where you can enter or edit the condition script logic as appropriate. For example, the following condition script requires that the source object CleanStatus evaluates to true in order for the record to be processed. If CleanStatus evaluates to false, then the node is skipped and this particular record will not be processed.

To view the full script editor with all available options for the condition script, click the popout icon  in the upper right. For details, see Script Editor. After opening the full script editor, click the return icon  to come back to this screen.

To edit or remove the condition, hover over the node name and click the actions menu icon  to open the actions menu. From the menu, select Edit Condition or Remove Condition:

For more information on this type of script, see Conditional Mapping.

  • No labels