LogoLogo
HomeCommunityLangstack.comCreate free account
  • 🤝Welcome
  • 🙌Support
  • 💡Get started
    • 📕Learn Langstack
      • Introduction to Langstack
        • Application templates
        • Storage frameworks
        • Account administration
      • Basics and essentials
        • What is an API gateway?
        • How to work with an API gateway
        • What is an Entity?
        • What is an Action box?
          • How to create and work with Action boxes
          • How to perform search in Actions
        • What is an Action?
          • How to create and work with Actions
          • Error propagation
          • Actions in Langstack applications
        • What is a Data type?
          • Simple Data types
        • What is a Variable?
          • Naming rules of a Variable
        • What is a Function?
          • Working with Functions
        • Navigating to a Variable or a Function
        • Implicit Type Conversion (ITC)
        • Explicit Type Conversion
        • Implicit and Explicit Type Conversion for Json
        • Next Steps
      • User management
        • What is a Privilege?
        • What are Groups?
        • What are Users?
      • Introduction to REST API
        • API Name
        • API Group name
        • Request and Response body
          • Request body
          • How to create and work with a Request body
          • Response body
          • How to create and work with a Response body
        • Query strings
          • How to create and work with Query strings
        • Headers
          • How to create and work with Headers
        • Path parameter
        • Create your first API: "Hello World!"
          • Working with API options
        • Exercise 1: GET REST API & Return Response Object
          • Step 1: Create API
          • Step 2: Test the API
        • Exercise 2: Delete a published API
        • Next Steps
      • Introduction to Entities
        • Fields
        • Records
        • Relations
        • Options for an Entity
        • Exercise 1: Customer Accounts and Activities
          • Customer accounts
            • Step 1: Create the Customers Entity
            • Step 2: Create the API
            • Step 3: Update entity through API
          • Customer Activities
            • Step 1: Create the Activities entity
            • Step 2: Create a “1 to Many” relation
            • Step 3: Create the API
            • Step 4: Update entity through API
        • Exercise 2: Customer Records
          • Step 1: Create the API
          • Step 2: Test the API
        • Next Steps
      • Programming with Entities
        • Create
        • Read
        • Update
        • Delete
        • JXPResponse
        • Next Steps
      • Using Triggers
        • After Create Trigger
        • After Update Trigger
        • After Delete Trigger
        • Exercise: Entity & Entity triggers
        • Step 1: Define “After Create” Trigger
        • Step 2: Define “After Update” Trigger
      • Connectors
        • Create a connector
        • SFTP Connector
        • MySQL Connector
        • Next Steps
      • Introduction to ETL pipeline
        • Create an ETL pipeline
        • Data Formats in ETL pipeline
          • Reader
          • Writer
          • Field mapping
        • Shared variables for ETL pipeline
        • ETL functions execution sequences overview
        • Displaying Functions
        • How to perform Search in ETL pipeline
        • Exercise 1: Skip Customer records
          • Step 1: Create the ETL pipeline
          • Step 2: Skip records based on Customer_ID
          • Step 3: Store skipped records in a list
          • Step 4: Store the Skipped Customer record
        • Exercise 2: ETL pipeline, CSV source & FTP Connector
        • Exercise 3: ETL pipeline, Database Source & MySQL Connector
        • Exercise 4: ETL pipeline, CSV Source & FTP Connector using Sections
          • Step 1: Create the ETL pipeline
          • Step 2: Reformat the Join_Date Values and define added fields
      • Multiple Executions, Time Duration, Linked App and Execution Status
        • Skip execution while in progress
        • Time duration settings
        • Linked App
        • Options for Delay Types
        • Execution status
      • Validation pipeline
        • Sequence of Validation pipeline
        • Exercise: Customer Information
          • Step 1: Create a Validation pipeline
          • Step 2: Create the API gateway
          • Step 3: Test the Validation pipeline
      • Introduction to Process
        • Create a process
        • Shared variables for a process
        • Exercise: Customer Anniversary Email Activity
          • Step 1: Check if the join date matches the current date
          • Step 2: Test the Process
      • Introduction to Flows & Flow components
        • What is a Flow?
        • What is a Flow component?
          • What is a Flow component Event?
        • Exercise 1: Customer Anniversary Email
          • Step 1: Create the Flow component
          • Step 2: Create the Flow
          • Step 3: Trigger the Flow
          • Step 4: Check records in the target entity
        • Exercise 2: Store list of customers
          • Step 1: Create the Flow component
          • Step 2: Create the Flow
          • Step 3: Create the API
    • 🌍Tour of Langstack (coming soon)
  • 📘In depth learning
    • 📖User Manual (coming soon)
    • 🔗Connectors
      • MS-SQL connector
        • Data type conversions between Langstack and MSSQL
        • Handling data loss in data type conversions
        • Setting up MS-SQL connector
        • MS-SQL connector as Reader and Writer
        • Using MS-SQL connector in ETL pipeline
          • MS-SQL connector as a source
          • MS-SQL connector as a destination
      • Google Drive connector
        • Set up Google Drive Connector
        • Adding Google Drive path in ETL pipeline Streams
        • Setting up GCP Account, GCP Project, API Enablement, and Credentials (Prerequisites)
          • OAuth 2.0 Client Credentials
          • Service Account Key Credentials
          • API Key Credentials
          • Authorization through Redirect URLs
        • Using Google Drive connector in ETL pipeline
          • Specifying file or folder paths
            • Direct file link
            • Folder link and file name
            • Folder path and file name
            • Folder path excluding file name
            • Folder path including file name
          • Google Drive connector as a source
          • Google Drive connector as a destination
      • AWS connector
        • Introduction
        • Set up AWS S3 Connector
          • OAuth 2.0 Client Type
          • Access Key
          • Public
        • Setting up AWS Account
          • Retrieve Client ID and Client Secret
        • Set up Amazon Web Services (Cognito) Console
          • Retrieve Identity Pool Id
          • Manage Permissions for Roles
          • Adding Redirect URL in Amazon Developer Console
          • User Consent for OAuth 2.0 Client through Login with Amazon
          • Retrieve Access Key Credentials
        • Creating a bucket in AWS
        • Using S3 connector in ETL pipeline
          • Specifying paths
          • Examples
            • AWS S3 connector as a source
            • AWS S3 connector as a destination
      • OneDrive connector
        • Set up OneDrive Connector
        • Setting up Microsoft Azure Account
        • Add URL to Authorized Redirect URLs
        • User Consent for Establishing OneDrive Connection
        • Usage of OneDrive Connector in ETL pipeline
          • Examples
          • OneDrive connector as a source
          • OneDrive connector as a destination
      • Dropbox connector
        • Set up Dropbox Connector
        • Setting up Dropbox Account
        • Add URL to Authorized Redirect URLs
        • User Consent for Establishing Dropbox Connection
        • Usage of Dropbox connector in ETL pipeline
          • Dropbox connector path settings
          • Examples
            • Dropbox connector as a source
            • Dropbox connector as destination
  • 🗃️Use Cases (Coming soon)
    • Use Case 1
    • Use Case 2
    • Use Case 3
Powered by GitBook
On this page
  1. Get started
  2. Learn Langstack
  3. Introduction to Flows & Flow components
  4. Exercise 2: Store list of customers

Step 1: Create the Flow component

PreviousExercise 2: Store list of customersNextStep 2: Create the Flow

Last updated 2 years ago

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.

By default, it is enabled. If this remains enabled then the Flow component will not be triggered for the other requests while one request is in progress. Since more than one request will be received simultaneously, if one customer request is in progress, other requests will be skipped.

  • 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:

    1. In the Mapped Field, enter “customer_id”.

    2. 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.

    1. 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.

    2. 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:

    1. Variable name: “requestJS”, Data type: “Json”. This variable contains the details received from the API.

    2. 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": "janedoe@mail.com", "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:

    1. Select Action as “Update Variable”.

    2. Select Target Value as “requestJS”.

    3. 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:

    1. Select Action as “Traverse List”.

    2. Select Target Value as Variables>requestJS>customerslist. It displays as “requestJS.customerslist”.

    3. 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:

    1. Variable name: “customer”

    2. 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:

    1. Select Action as “Update Entity fields from json”. This action updates entity fields from the matching fields in the Json.

    2. Select Target Value as “customer”.

    3. Select Source Value as Variables>item. It is displayed as “item”.

    4. 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:

    1. Select Action as “Create Entity record”. This action creates a new record to the Target Entity.

    2. 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.

    3. 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.

💡
📕