Docs Menu
- Introduction to Syncloop
- Quick Start Syncloop
-
API Developer Guide
-
middleware
-
pub
- adapter
- authorization
- client
- collection
- date
- docList
- file
- graphQL
- io
- json
- jwt
- math
- platform
- security
- server
- service
- specs
- sql
- string
- bytesToHexString
- bytesToString
- compare
- compareStrings
- concat
- decodeBase64
- decodeHTML
- encodeBase64
- encodeHTML
- equals
- equalsIgnoreCase
- escapeSQL
- fromXML
- htmlDecode
- htmlEncode
- indexOf
- isAlphanumeric
- isBlank
- isDate
- isEmpty
- isNumber
- length
- lookupDict
- maskString
- messageDigest
- messageFormat
- NullOrWhiteSpc
- objectToString
- padLeft
- replace
- rightPad
- stringConcat
- stringIndexOf
- stringToBytes
- subString
- TextArrayToTextString
- TextListCollector
- tokenize
- toLower
- toString
- toUpper
- trim
- urlDecode
- tenant
- util
- xml
-
pub
-
middleware
- User Guide
- FAQs
- Java Docs
- Blogs
The MAP Statement
The MAP statement is a commonly used feature on the platform that allows various operations within the Syncloop workspace. This documentation aims to provide a comprehensive understanding of the MAP statement and its functionalities.
Creating a MAP Statement
To create a MAP statement, right-click on the Control Flow section and select MAP from the context menu strip. The MAP statement will be generated in the Control Flow section of the Syncloop workspace.
A MAP statement is used in the Syncloop workspace for conducting the following operations.
Creating a new variable/element and assigning a value to it.
If the variable is already created, you can drop it in the next step.
Mapping of two variables.
Customise Mapping using Custom Mapping Configuration feature
Creating a new variable under MAP step
To create a new variable, you can utilize the MAP statement.
Simply click on MAP to access the input and output section of the MAP statement.
In the response section, right-click and choose the option to create a new variable. Select the data type to create any variable type within the Output section.
Operations Performed on Variables
The tools available in the Input and Output sections of the workspace are shown below:
To assign a value to the string variable test click on the pencil icon in the toolbar and assign a value Blank to it.
Let's discuss all the options provided in the Set Dialog:
Once the value is assigned to the variable a pencil sign is visible with the variable name under that map.
Multiple MAP Statements
In addition to creating a single MAP statement, it is also possible to create multiple MAP statements and access variables that were created in previous MAPs. It is even possible to drop variables that have already been created in earlier MAP statements.
To demonstrate this feature, let's consider an example where we have multiple MAP statements. When we select a different MAP statement that was recently created, the pencil icon associated with the variable is no longer visible. Additionally, we notice that the variable "test" is repeated in both the request and response sections of this subsequent MAPs.
This indicates that the variable is not created within the current MAP statement. Each MAP statement represents a distinct step in the service. If we want to eliminate the need for the variable in subsequent steps, we can choose to drop it.
To drop the variable "test" in the above example, select the variable and click on the drop tool located in the response section.
Once a variable is dropped, it cannot be referenced in any subsequent MAP statements.
Now, when we create a new MAP statement, we observe that the variable "test" is not repeated in either the request or response sections. This is because it was dropped in the previous step, effectively removing it from the service flow.
Mapping two Variables
This step is crucial for propagating variable values within the platform. To create a new variable called test2, follow the instructions below:
Locate the second MAP statement.
In the Request section, find the variable named test.
Click and drag the test variable to map it with the test2 variable in the Response section.
By performing this mapping, the value of the test variable will be assigned to the newly created string variable test2.
The mapping operation can be represented programmatically as follows:
test2 = test
Custom Mapping Configuration
The Custom Mapping Configuration option is used to customize the mapping between two variables. This feature allows for the modification of existing mappings according to specific requirements. To illustrate this, let's create an example using the API Custom Mapping.
Follow the steps below to implement Custom Mapping Configuration:
Create a MAP statement in the workspace.
In the Response Section, create an integer variable called "intA" and assign the value of 10 to intA.
Create another MAP in the workspace and create an integer variable named "intB" in the output section.
Create an integer variable "intB" as the output parameter.
Click on another map and map "intA" and "intB" as shown in the video.
At this point, we have two variables, "intA" and "intB", which will be involved in this mapping process.
To enable custom mapping, the desired mapping line needs to be selected. Click on either end of the line until it turns red, indicating that it has been selected.
Once the line is selected, locate and click the "Custom Mapping Configuration" tool in the toolbar. This action will open a dialog box specifically for custom mapping configuration.
The various options provided in the dialog are explained in the table below:
To configure custom mapping, follow these steps:
- Select the method as "custom" and write the code in the
function(val)
section.
function(val) { val = val + 10; return val; }
By default, the
intA
variable is assigned a value of 10. When the mapping is executed, the value ofintA
will pass through theval
variable. Therefore,intB
will be assigned a value of 20, asval = 10 + 10 = 20
.Execute the Service Endpoint on the browser to see the result.
Result:
To modify the service and add an input value to the variable intA
, follow these steps:
Create an integer input parameter named
intInput
.Inside the function, write the code as shown in the figure.
val = val + $(intinput);
return val;
After modifying save the service and test it using the Postman application.
For example, if the input value is 200, the mapping function will add the value of 10 to the input value, resulting in intB = 210
.
Please note that if the condition option of Custom Mapping Configuration is set to false, the mapping will not take place, and it will result in an error.
To implement the Custom Mapping Configuration feature successfully, ensure that the condition remains true.