Step 1: Create the Flow component
The first step is to create a Flow component.
To open the Flow component template, click โFlow componentโ under the โBackground processesโ menu on the left side panel.

To create a new Flow component, click [+ Flow component].

The โDetailsโ tab is selected by default.
To label the Flow component, enter a meaningful Flow component name. In this exercise, label it as โUserName_createlistofcustomersโ.
To elaborate on the purpose of this Flow component, enter a description.
To store information/logs regarding the execution of the Flow component and associated events, create a โFlow Progression Entityโ labeled as UserName_flowApp_progressionโ by clicking the [+] button.

To enable execution of multiple requests, disable โSkip execution while in progressโ by clicking the toggle button.


To define the Mapped Fields, expand the โField Mappingโ section by clicking on the arrow. Mapped Fields are input fields for this Flow component. (When the Flow component is placed in a Flow, the user can assign values to these fields in the form of constant text or from relevant sources before executing the Flow.) To create a new field, click [+ Field].

To define the mapped field for this Flow component, go to the Field Mapping section. select the following values:
In the Mapped Field, enter โcustomer_idโ.
The data type is selected as โstringโ. Keep as is for this exercise. Note: At least one mapped field is mandatory in a Flow component. In this case, it has been defined as customer_id.

To expand the โEventsโ section, click on the โEventsโ arrow. In this section, the users define the events that may be triggered during the execution of the Flow component.

To view the predefined Events for this Flow component, go to the Events section. By default, four (4) events are already created and enabled. For this exercise, do not create additional events.

To view the predefined variables for the Flow component, go to the โVariablesโ tab. Two (2) variables are already defined to store the values entered by the user in defining the Flow component Mapped Fields.
Variable Name: โSourceโ, Data Type: โJXPFlowAppActivityโ. This variable contains a number of elements relevant to the Flow component activity in a Flow that hold a certain value.
Variable Name: โMappedFieldsโ, Data Type: โjsonโ. Mapped fields contain the values in Json format.

To create a new โTarget entityโ, go to the โTarget Entitiesโ tab and click the [+ Target entity] button.

Select the Target entity as โUserName_Acc_customersโ from the drop-down menu. This is the entity where the customer records will be created once triggered in the Flow.

To define a sequence of actions to create an entity record in the target entity, go to the โCodeโ tab. To create a new โAction boxโ, click the [+ Action box] button.

The โAction boxโ is default labeled as โDescriptionโ. To make the description of the โAction boxโ more meaningful, click on the โDescriptionโ text and enter the text as โcreate anniversary email recordโ. In this โAction boxโ, the necessary actions will be added and configured to create an anniversary email record for the customer.

To define the variables for this โAction boxโ, go to the โVariablesโ tab. To create a new variable, click the [+ Variable] button.

To define the variables to receive the Json request from the API and send the response, create two (2) variables. Define the variables as follows:
Variable name: โrequestJSโ, Data type: โJsonโ. This variable contains the details received from the API.
Variable name: โresultโ, Data type: โJXPHttpRestResponseโ. This variable contains the Rest Response.

To add a sample of the โrequestJSโ variable, click the [Sample] button.

To define the sample Json, add the following Json in the Sample Schema View. This Json defines that a list of customers will be stored in this variable.
{ "customerslist": [{"Address": "first Street","City": "","Customer_Value": 5,"Country": "USA","Email": "[email protected]","First_Name": "Jane","IsActive": true,"Join_Date": "2021-09-15","Last_Name": "Doe","Phone": "1237865","Rating": 1000,"Zip_Code": "45" }]}The sample Json will look as per the image below. The โcustomerslistโ becomes a field in the โrequestJSโ variable. (The same sample will also be added in the API during API creation.) To save the settings, click the [Save] button.

To create the actions for this Flow component, go to the Code tab and create a new Action by clicking the (+) button.

To store the details from the API source in the Json variable, define the first Action as follows:
Select Action as โUpdate Variableโ.
Select Target Value as โrequestJSโ.
Select Source Value as Variables>Source>Details. It displays as โSource.Detailsโ.

To traverse the list of customers received, add another Action and define it as follows:
Select Action as โTraverse Listโ.
Select Target Value as Variables>requestJS>customerslist. It displays as โrequestJS.customerslistโ.
The field โTreat each element in the list asโ is populated with the Variable โitemโ. The โitemโ represents the individual item in the list being traversed.

The โitemโ variable is automatically listed in the Traverse List variables. To define variables to store the entity record, add a variable by clicking the [+ Variable] button.

To store entity fields, define the variable as follows:
Variable name: โcustomerโ
Data type: โUserName_Acc_customersโ

To load the entity fields from the matching fields in the item (Json), add a new Action in the Traverse List Action and define it as follows:
Select Action as โUpdate Entity fields from jsonโ. This action updates entity fields from the matching fields in the Json.
Select Target Value as โcustomerโ.
Select Source Value as Variables>item. It is displayed as โitemโ.
Select โunset missing valuesโ. So that If the field is not found in the json request, the Action will set the field in the target variable as unset.

To create an entity record after the entity fields are loaded, add another Action in Traverse List Action by clicking the (+) button and define it as follows:
Select Action as โCreate Entity recordโ. This action creates a new record to the Target Entity.
Add a new variable by clicking [+] and name it as โcreateResultโ. Click the [Save] button to save this variable. This variable will be the data type JXPResponse variable and will display the success or failure of the record creation. Also, this variable will be automatically created in the variables tab of the traverse action.
Select Entity variable as โcustomerโ.

To save the Flow component, click the [Save] button.

To publish the Flow component, click the [Publish] button.

To enable the Flow component, ensure it is enabled.

Last updated
