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 new script as a project component is done through the project pane or the design canvas:

  • Project Pane: In the Components tab of the project pane, hover over the category Scripts and click the actions menu icon  to open the actions menu. From the menu, select Create New to create a new, unreferenced script:

    On creating the script, the cursor is positioned on the script name within the project pane for you to rename the script.

  • Design Canvas: Within a new or existing operation, click the component block to open the actions menu. From the menu, select New Script:

    A new, blank script is automatically added to the operation and the script editor opens. For further details, see Adding Steps to an Operation under Operation Creation and Configuration.

After a script is created, menu actions for that script are accessible from the project pane or the design canvas:

  • Project Pane: In the Workflows or Components tab of the project pane, hover over a script name and click the actions menu icon  to open the actions menu.

  • Design Canvas: Within the operation, click the existing script block to open the actions menu.

Each of these menu actions is available:

  • View/Edit: Opens the script editor for you to build the script (see Script Editor).
  • Delete: Permanently delete the script (see Component Dependencies, Deletion, and Removal).
  • Rename: Positions the cursor on the component name in the project pane 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).
  • Remove: Available only from the actions menu on the design canvas, removes the script as a step in the operation without deleting it from the project. Removed components can be accessed or permanently deleted from the project pane (see Component Dependencies, Deletion, and Removal).
  • Deploy: Deploys the script and any components it is dependent on (see Component Deployment).
  • Configurable Deploy: Opens the deployment screen, where you can select project components to deploy (see Component Deployment).
  • Add to Group: Opens a prompt to create a new custom group or to add the component to an existing group. Custom groups are an organizational tool to help organize a project (see Component Groups).
  • Duplicate: Creates a copy of the script as a new, unreferenced component. On creating the component copy, the cursor is positioned on the component name within the project pane for you to rename the component.

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 and is limited to Jitterbit Script language.

To add a new script on a target field, in either mapping mode or script mode, 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, in either mapping mode or script mode, click the script icon  in the top right of a target field.

This opens 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. Once within 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 and is limited to Jitterbit Script language. Conditions can be added as scripts on target nodes in any level of a data structure.

From either mapping mode or script mode, 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. Once within the full script editor, click the return icon  to come back to this screen.

To edit or remove the condition, from either mapping mode or script mode, 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.

On This Page

Last updated:  Nov 19, 2020

  • No labels