Logical Functions¶
Use the logical functions to control the flow of Jitterbit scripts.
Note
 The maximum number of loop iterations allowed in Jitterbit Harmony is 50,000.
 The maximum number of loop iterations in Jitterbit Script Language is per each individual loop. To increase the allowed number of iterations per loop in a Jitterbit Script Language script, see jitterbit.scripting.while.max_iterations in Scripting Jitterbit Variables.
 The maximum number of loop iterations in JavaScript is per script (aggregate of all loops within one script). To increase the maximum number of loop iterations in JavaScript, see Java Script Loop in JavaScript.
Case
¶
Declaration¶
typeN Case(bool b1, type1 arg1[, bool b2, type2 arg2,... bool bN, typeN argN])
Syntax¶
Case(<b1>, <arg1>[, <b2>, <arg2>,... <bN>, <argN>])
Required Parameters¶
b1:
An expression to be evaluated for its boolean resultarg1:
An argument to be returned ifb1
istrue
Optional Parameters¶
b2... bN:
Additional expressions to be evaluated for truthinessarg2... argN:
Additional arguments to be returned if the matching parameter istrue
Description¶
This function evaluates pairs of arguments: if the evaluation of the expression in the first argument of a pair is true
, it stops checking and returns the second argument with the type preserved. Otherwise it will check the next pair, and so on. If none of the pairs evaluate to true
, null
is returned.
To create a default or fallthrough case, use true
and the desired return value as the last pair. See the example.
Examples¶
This example returns "Very Expensive"
if price
is 1000
or higher. The true
in the last pair of arguments serves as the default or fallthrough case.
$label = Case(price < 10, "Cheap",
price < 100, "Not Cheap",
price < 1000, "Expensive",
true, "Very Expensive");
Equal
¶
Declaration¶
bool Equal(type1 array1, type2 array2)
bool Equal(type1 arg1, type2 arg2)
Syntax¶
Equal(<array1>, <array2>)
Equal(<arg1>, <arg2>)
Required Parameters¶

array1, array2:
(First form) Two arrays of the same length and dimension; if not, the function returnsfalse

arg1, arg2:
(Second form) Two simple types or expressions
Description¶
Performs a recursive comparison of two arrays. Returns true
if all corresponding members of the arrays are equal, otherwise it returns false
. It can also be used with simple types, and follows conversion rules to promote different types to compare them.
Calling this function to compare two arrays is different from using the ==
operator on two arrays. Using the ==
operator on two arrays returns an array of booleans containing the result of a comparison of each array member. Using this function compares each corresponding element in turn.
The Equal()
function always returns false if the two array arguments have different sizes.
Type conversion and promotion is performed if the arguments or elements being compared are of different types.
Examples¶
x = {1, 2.0, 3};
y = {1, 5, 3};
// Returns false since 2.0 != 5
Equal(x, y);
// Returns true because both arrays contain only nonzero numbers.
// Comparison is made as booleans
Equal(Bool(x), y);
If
¶
Declaration¶
typeN If(bool condition, type1 trueResult[, type2 falseResult])
Syntax¶
If(<condition>, <trueResult>[, <falseResult>])
Required Parameters¶
condition:
An expression to be evaluated for its boolean resulttrueResult:
An expression to be evaluated and its result returned ifcondition
istrue
Optional Parameters¶
falseResult
: An expression to be evaluated and its result returned if condition is false
Description¶
Returns trueResult
if condition is true, else it returns falseResult
.
If the first argument (condition
) is not a boolean data type, it is converted to a boolean before it is evaluated. If the optional third argument is not specified and condition
is false
, a null
value is returned.
Examples¶
// Returns "Diane"
If(false, "Jack", "Diane");
// Returns "Spoon"
If(7>4, "Spoon", "Knife");
// Adds a trailing comma to s if s is not empty
If(Length(s)>0,
s = s + ",";
);
While
¶
Declaration¶
null While(bool condition, type expression)
Syntax¶
While(<condition>, <expression>)
Required Parameters¶
condition:
An expression to be evaluated for its boolean resultexpression:
An expression to be evaluated repeatedly as long ascondition
istrue
Description¶
Repeatedly executes an expression as long as a condition is true.
The Jitterbit variable jitterbit.scripting.while.max_iterations
limits the number of iterations. An error is reported if the maximum number of iterations is reached.
Examples¶
$jitterbit.scripting.while.max_iterations = 2000;
i = 0;
arr = {"a@example.com", "b@example.com", "c@example.com"};
s = "";
// Concatenates the elements of the array arr
// with commas separating each element
While(i < Length(arr),
s = s + Get(arr,i) + ",";
i++;
);