Gateway supports several data types, operators, and statements. Refer to the sections below for more information on Gateway supported data types and programming constructs.
Supported Data Types
The following table lists Gateway data types supported in Primavera Gateway.
Supported Data Type | Example | Note |
---|---|---|
Boolean |
| Boolean values can be set as either |
Date |
| The Date must be in the ISO format No other formats are allowed. |
Double |
|
|
Integer |
| Assignment expressions in math such as / or * that have double values as part of the expression will truncate the decimal. In the example, |
Object reference |
| References to all the fields of the object are included by default once you declare an object variable. |
null Note: You can set a variable of any data type to null, but you cannot create a null type variable. |
|
|
String |
|
|
Operators
Gateway scripting language provides operators for computation and comparison. Operators can only be applied to data types they support. The following tables list operators supported in Gateway code.
- Supported Numeric Operators
- Supported Logical Operators
Supported Numeric Operators
Use numeric operators to perform calculations on numeric data types, such as doubles.
Operator | Name | Description | Applicable Data Types | Return Data Type | Example |
---|---|---|---|---|---|
+ | Addition | Sums two Double values. | Double | Double |
|
- | Subtraction | Subtracts two Double values. | Double | Double |
|
* | Multiplication | Multiplies two Double values. | Double | Double |
|
/ | Division | Divides two Double values. | Double | Double |
|
Supported Logical Operators
Supported logical operators to manipulate and combine Boolean values and to construct conditional statements.
Operator | Name | Description | Applicable Data Types | Return Data Type | Example |
---|---|---|---|---|---|
|| | OR | Returns the result of combining Boolean values using a logical OR. If one value or expression contained in the OR statement evaluates to true, the OR expression returns true. | Boolean | Boolean |
|
&& | AND | Returns the result of combining Boolean values using a logical AND. If both values or expressions in the AND statement evaluate to true, the AND expression returns true. | Boolean | Boolean |
|
! | NOT or Inversion | Negates the specified Boolean value. Applying the NOT operator to an expression that evaluates to true will return false. | Boolean | Boolean |
|
Supported Comparison Operators
Use comparison operators to measure values against each other. The data types of compared values must match, otherwise the application will return an error. The result of a comparison operation is a Boolean, true or false.
Operator | Name | Description | Applicable Data Types | Return Data Type | Example |
---|---|---|---|---|---|
== | Equal | Tests if two values are equal. | All | Boolean |
|
!= | Does Not Equal | Tests if two values are not equal. | All | Boolean |
|
> | Greater Than | Tests if one value is greater than another. | All | Boolean |
|
>= | Greater Than or Equal To | Tests if one value is greater than or equal to another | All | Boolean |
|
< | Less Than | Tests if one value is less than another. | All | Boolean |
|
| Less Than or Equal To | Tests if one value is less than or equal to another. | All | Boolean |
|
Supported Special Operators
Use special operators to create structure in your Gateway code and specify how Primavera Gateway should interpret and execute the expressions.
Operator | Name | Description | Applicable Data Types | Example |
---|---|---|---|---|
+ | Concatenation | Combines a String with another data type, yielding a new String. String concatenation is applied when the leftmost operand of the + operator is of the data type String. The right operand can be a value of any type. When concatenated, Date values may not serialize in the format anticipated.
| String |
|
= | Assignment | Assigns a value of a supported data type to a variable. | All |
|
Supported Gateway Statements
Gateway supports a variety of statements you can use to determine the control flow of Gateway code. The following tables list Gateway statements.
Statement | Description | Example |
---|---|---|
add | Adds an object to the synchronization. Objects that are added will be sent to the destination. |
|
delete | Removes objects and fields from the synchronization. Objects and fields that are removed, will not be sent to the destination. Note: Does not necessarily remove the object from the destination application. |
|
{ } (block) | Specifies a sequence of expressions to evaluate. Used to structure Gateway scripts, establish variable scope, and improve readability. Variables defined and assigned values within a code block are accessible only within the code block and other structures the code block contains. |
|
for loop | Iterates over the objects of a specific type in Gateway. | //Iterates over all of the resource objects to find a resource rate that exists for the given resource and date. If no ResourceRate is found, a new one will be created. At the end, all resource objects are removed. for (resource: <Resource>) { <ResourceRate> resRate = <ResourceRate>.findOne(rr2 -> (rr2.ResourceObjectId == resource.ObjectId) && (rr2.EffectiveDate == 2019-12-20T00:00:00)); if (resRate == null) { <ResourceRate> rr = new <ResourceRate>; rr.ObjectId = -100; rr.EffectiveDate = 2019-12-20T00:00:00; rr.ResourceObjectId = resource.ObjectId; rr.PricePerUnit = 5; add rr; } }
//remove all resource objects delete <Resource>;
|
find one | Returns an object when the given condition is met. |
|
if | Code contained in an if block will only be evaluated if the condition specified by the if statement evaluates to true. |
|
if/else | Code contained in an if block will only be evaluated if the condition specified by the if statement evaluates to true. If the specified condition evaluates to false, code in the else block will be evaluated. |
|
if/else if | Code contained in an if block will only be evaluated if the condition specified by the if statement evaluates to true. If the specified condition evaluates to false, code in the if else block will be evaluated. If the specified condition evaluates to false in the if else block, then the next block of if else code will be evaluated. Note: Any number of if else blocks can be specified. |
|
new | Creates an empty object. |
|
parameter | Creates a parameter using the following syntax: Parameter["parameter name"] = "parameterValue"; | Parameter["SomeParameter"] = "someValue"; Parameter["parameter name"] = "parameterValue"; string someVar = Parameter["SomeParameter"]; Parameter["SomeParameter", "Unifier"] = "someValue"; string someVar = Parameter["SomeParameter", "Unifier"];
|