Skip to end of metadata
Go to start of metadata

Overview

Jitterbit variables are one of the types of global data elements available in Jitterbit Harmony. The other types of global data elements—project variables, global variables, and filename keywords—are also available globally throughout a project. They are set differently, as described in Project Variables, Global Variables, and Filename Keywords, respectively. However, as all global data elements share the same namespace, their names must be unique when compared against all other global data elements.

The most common use case for Jitterbit variables is to read a variable so that you can gather information about what occurred during an operation or to fetch global information such as the name of the current source file. Another common use case is to use Jitterbit variables to change default settings used for processing the operation chain.

If using a Private Agent, you can programmatically change the behavior of Jitterbit by changing the default value of a predefined Jitterbit variable or by creating and predefining your own Jitterbit variable. Creating or updating Jitterbit variables is not available for the Cloud Agent Groups.

Refer to these pages for documentation on the predefined Jitterbit variables:

Display of Jitterbit Variables

Jitterbit variables are displayed in several places:

  • In the script editor, Jitterbit variables are displayed in the component palette on the right within the Variables tab in the Jitterbit Variables sub-tab. This location provides easy access for inserting Jitterbit variable references in scripts, including within transformation scripts in script mode.
  • In transformation mapping mode, Jitterbit variables are displayed within the Variables tab on the left in the Jitterbit Variables category. This location provides easy access for inserting Jitterbit variable references during transformation mapping in mapping mode.
  • In endpoint configuration screens, Jitterbit variables can be accessed and used in any fields that have a variable icon . As an alternative to selecting a Jitterbit variable, you can manually enter the variable reference using the standard Jitterbit Script square bracket syntax.

Setting Jitterbit Variables in Scripts or Transformations

While the most common use case for Jitterbit variables is to read information, there are some Jitterbit variables that you may want to set in order to communicate something to an agent. In Cloud Studio, Jitterbit variables can be set using either Jitterbit Script or JavaScript, in the same way that any global variable can be set.

TIP: Refer to the documentation for each Jitterbit variable for information on which variables can be set and what they can be set to.

Jitterbit Script

In Jitterbit Script used within scripts and transformations, the value of a Jitterbit variable can be set by beginning with a dollar sign $ or by calling the Set() function.

  • $: Using the dollar sign $ syntax, $jitterbit.api.response="Success" sets the API response (jitterbit.api.response) to return the string "Success" to the requesting application. 
  • Set: Using the Set() function, Set("jitterbit.api.response", "Success") sets the API response (jitterbit.api.response) to return the string "Success" to the requesting application.

In scripts and transformations, Jitterbit variables are also displayed in the Variables tab of the script component palette, inside the Jitterbit Variables sub-tab. See Adding a Jitterbit Variable to a Script below.

JavaScript

In JavaScript used within scripts created as a project component, Jitterbit variables predefined by Jitterbit are able to be set only with the Jitterbit.SetVar() function. This is because all Jitterbit variables predefined by Jitterbit contain periods within the variable name.

  • Jitterbit.SetVar: Using Jitterbit.SetVar, the code example Jitterbit.SetVar("$jitterbit.api.response", "Success") sets the API response to return the string "Success" to the requesting application.

WARNING: The JavaScript Jitterbit.SetVar and Jitterbit.GetVar functions are designed specifically to access the predefined Jitterbit variables. They are not to be used to access user-defined global variables. 

In JavaScript, do not mix and match your usage of SetVar (and GetVar) with $-prefacing when setting (and retrieving) a variable. Use only one syntax. Mixing the two different syntaxes for the same variable can cause issues at runtime.

In scripts and transformations, Jitterbit variables are also displayed in the Variables tab of the script component palette, inside the Jitterbit Variables sub-tab. See Adding a Jitterbit Variable to a Script below.

Retrieving Jitterbit Variables in a Script or Transformation

The value of a Jitterbit variable can be returned using either Jitterbit Script (in scripts or transformations) or using JavaScript (only in scripts created as a project component) in the same way a global variable can be retrieved.

WARNING: There is a known issue that mapping variables with periods in the variable name doesn't work correctly, resulting in an incorrect target field mapping in the transformation. Until this issue is resolved, Jitterbit variables are unable to be directly referenced within a transformation. Scripting can be used to create a workaround mechanism to pass values.

Jitterbit Script

In scripts and transformations, you can begin with a dollar sign $ or use the Get() function to retrieve the value of a Jitterbit variable:

  • $: Prefixed with a dollar sign $, the code example $jitterbit.operation.error retrieves the value of the Jitterbit variable "jitterbit.operation.error".
  • Get: Using the Get() function, the code example Get("jitterbit.operation.error") returns the same value.

In scripts and transformations, Jitterbit variables are also displayed in the Variables tab of the script component palette, inside the Jitterbit Variables sub-tab. See Adding a Jitterbit Variable to a Script below.

JavaScript

In JavaScript scripts within an operation, Jitterbit variables predefined by Jitterbit are able to be accessed only with the Jitterbit.SetVar() and Jitterbit.GetVar() functions. This is because all Jitterbit variables predefined by Jitterbit contain periods within the variable name.

  • Jitterbit.GetVar: Using Jitterbit.GetVar, the code example Jitterbit.GetVar("$jitterbit.operation.error") returns the value of the Jitterbit variable called "jitterbit.operation.error". Note that a leading dollar sign $ is optional before the name when retrieving values. The names jitterbit.operation.name and $jitterbit.operation.name are equivalent when retrieving values.

In scripts and transformations, Jitterbit variables are also displayed in the Variables tab of the script component palette, inside the Jitterbit Variables sub-tab. See Adding a Jitterbit Variable to a Script below.

WARNING: The JavaScript Jitterbit.SetVar and Jitterbit.GetVar functions are designed specifically to access the predefined Jitterbit variables. They are not to be used to access user-defined global variables. 

In JavaScript, do not mix and match your usage of SetVar (and GetVar) with $-prefacing when setting (and retrieving) a variable. Use only one syntax. Mixing the two different syntaxes for the same variable can cause issues at runtime.

Adding a Jitterbit Variable to a Script

In either Jitterbit Script or JavaScript used within scripts created within an operation, Jitterbit variables are displayed in the Variables tab of the component palette, inside the Jitterbit Variables sub-tab:

Add a variable to a script using one of these methods:

  • Drag the variable from the palette to the script. The appropriate syntax for the script language is inserted.
  • Begin typing the variable name and then press Control+Space to display a list of autocomplete suggestions. Select a variable to insert the appropriate script language syntax.
  • Manually enter the appropriate syntax for Jitterbit Script or JavaScript.

Using Jitterbit Variables in Configuration Screens

During configuration of various project components, including endpoint configuration using connectors, you can use Jitterbit variables in any fields that have a variable icon . Variables can be used in fields along with other input, including with other variables or keywords. These actions are covered below:

Selecting a Jitterbit Variable

To access Jitterbit variables, you can either click the variable icon  or enter an open square bracket [ to display a list of variables and keywords (if available for the current field).

Within the list, the variable or keyword type is indicated by the icon next to its name:

  •  for filename keyword
  •  for global variable
  •  for project variable
  •  for Jitterbit variable

In the list, hover over the variable name to preview information about it:

The Value and Description that appear in the information popup are always empty for a Jitterbit variable. For a description of how each variable is used, refer to the pages under this topic.

A default value for a Jitterbit variable cannot be defined in a configuration field. Instead, you can set values for certain Jitterbit variables in a script to be evaluated at runtime.

Select a variable to add to the field at the location of your cursor, anywhere in the string. The variable is displayed in a pill format similar to that shown below:

To review information about the variable, hover over the variable pill:

Toggling Formats Between Pill and Text

To change the default variable pill format to text format, click the collapse icon :

 This toggles the display of the pill format to a text format, with the variable name enclosed within square brackets [ ]:

To change from a text format back to pill format, change focus off of the field, such as by clicking into another configurable field. The field input automatically returns to the default pill format.

Removing a Variable

To remove the variable, click the remove icon :

Jitterbit Variable How-tos

This section includes details on using Jitterbit variables in projects.

Creating New Variables or Setting Defaults on Private Agents

Those using Private Agents can programatically change the default behavior of Jitterbit variables as well as create new Jitterbit variables through the Private Agent configuration file. However, note that this is used only in rare use cases implemented by advanced users. Most use cases can be handled by creating a project variable rather than a Jitterbit variable.

Changing default values or creating new Jitterbit variables is done from these sections of the Private Agent configuration file:

  • [PredefinedGlobalVariables]
    Check or change default values for Jitterbit variables.
  • [PredefinedServerGlobalDataElement]
    Define your own custom Jitterbit variables and default values.

Jitterbit variable names can be composed of these characters: letters (a-z, A-Z), numbers (0-9), periods, and underscores. Other characters are not recommended and may cause issues.

NOTE: On upgrading a Private Agent, the configuration file is preserved, and is not overwritten with the latest version.
WARNING: When creating new Jitterbit variables, using periods in a variable name is not recommended if you plan to access them with JavaScript. Instead, it is recommended that you create Jitterbit variables that do not contain periods and instead use underscores in place of periods. Refer to information on global variables, which is also applicable to Jitterbit variables.

For more information about editing or creating Jitterbit variables, see Editing the Configuration File - jitterbit.conf.

On This Page

Search in This Topic

Last updated: Jun 12, 2020

  • No labels