Skip to end of metadata
Go to start of metadata

Overview

The Jitterbit Harmony system defines certain global variables that are always available throughout your project, known as Jitterbit variables or as predefined global variables.

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.

Jitterbit variables are displayed in several places:

  • From 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.
  • From 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.
  • From 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 square bracket syntax.

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

Using 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 any other global variable can be retrieved.

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 gets 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 will also be displayed in the Variables tab of the component palette inside the Jitterbit Variables sub-tab:

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

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

JavaScript

In JavaScript used within scripts created within an operation, Jitterbit variables predefined by Jitterbit are able to be accessed only with the Jitterbit.GetVar function. 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") gets the value of the global variable called "jitterbit.operation.error". Note that the dollar sign $ must be included within the variable name.

In JavaScript used within scripts created within an operation, Jitterbit variables will also be displayed in the Variables tab of the component palette inside the Jitterbit Variables sub-tab:

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

  • Drag the variable from the palette to the script. The appropriate syntax for the script language will be inserted.
  • Begin typing the variable name and then press Control+Space (or Command+Space on Mac) to display a list of autocomplete suggestions. Select a variable to insert the appropriate syntax for JavaScript.
  • Manually enter the appropriate syntax for 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 .

Single Variable

To use a single variable as the only value within the field, click the variable icon  to display a list of keywords and variables.

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

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

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

NOTE: The value and description for a Jitterbit variable always appears to be empty.

Select a variable to replace the contents of the field. Any existing input entered within the field, if present, will be replaced with the variable. A single variable used as input in a field is displayed in a pill format similar to that shown below:

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

To change the pill format to text to use with additional input, with each variable displayed within square brackets [ ] , click the collapse icon .

To clear the field, click the remove icon .

Variables with Additional Input

To use a variable along with other field input, including with other keywords or variables, enter an open square bracket [ into the field. From the list, hover over the variable name to preview information about it. Select a variable to insert the variable at the location of your cursor, anywhere in the string:

Variables entered using this method are displayed as text within square brackets [ ] within the field. Enter any additional input or add multiple variables using the same method described above:

Variables with Default Values

To define a default value, specify it within curly brackets { } immediately following the Jitterbit variable name, within the square brackets [ ]:

 

When default values are specified, the Jitterbit variable value will be used if it is defined, else the default value will be used.

Setting Jitterbit Variables in a Script or Transformation

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

TIP: Refer to the documentation for each Jitterbit variable for information on what 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 beginning with a dollar sign $ or by calling the  Set  function.

  • $: Using the dollar sign $ syntax, the code example $jitterbit.api.response="Success" sets the API response to return the string "Success" to the requesting application. 
  • Set: Using the Set function, the code example Set("jitterbit.api.response", "Success") sets the default value of the same variable.

JavaScript

In JavaScript used within scripts created within an operation, 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. 

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: Upon 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:  Oct 08, 2019

  • No labels