Gateway supports a variety of statements you can use to determine the control flow of Gateway code.
These include:
Statement | Description | Example |
---|---|---|
abort | Stops a job and marks it as Failed with a message provided in the formula. You can use this statement to test for a specific scenario and if found, stop the job from processing. Syntax: |
|
add | Adds an object to the synchronization. Objects that are added will be sent to the destination. |
|
attribute | Determines what action to take on a row of data. Valid actions to execute include: create or update. Syntax: | setAttribute("action", "create"); |
Child Object | Finds a child object of an object (Code/UDF) based on an object and used in the formula. Note: Use this statement to only find an object. You cannot create a new object. |
|
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. |
|
Field | Use a field within a formula after it has been removed by the Compare Step. Note: To use this option if the field will be removed, place the Custom Step after Compare and before the Convert to Destination Format step. |
|
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", "parameter provider"] = "parameterValue"; | Parameter["SomeParameter", "Unifier"] = "someValue"; Parameter["parameter name", "Primavera Cloud"] = "parameterValue"; string someVar = Parameter["SomeParameter"]; Parameter["SomeParameter", "Unifier"] = "someValue"; string someVar = Parameter["SomeParameter", "Unifier"];
|