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. Using Triggers

Step 1: Define “After Create” Trigger

PreviousExercise: Entity & Entity triggersNextStep 2: Define “After Update” Trigger

Last updated 2 years ago

To define the "After Create" trigger, follow the steps below:

  • To go to the Entity database, click “Entity database” under the “Database” menu on the left side panel.

  • Select the entity “UserName_Acc_customers”. To define the triggers for the entity, go to the Triggers tab.

  • To create the After Create Trigger, click the [+ After Create] button.

  • Click on the text “New_Trigger_0” and label the After Create Trigger as “updateDayMonthJoinDate”. This trigger will update the DayMonthJoinDate field with a value of day and month based on the value in the Join_Date field.

  • To define variables for this trigger, go to the “Variables” tab of the Trigger. A variable “Created_Record” with data type as “UserName_AcccCustomers” entity is already defined.

  • To create a variable, click the [+ Variable] button. Create four (4) more variables.

  • To store the values for list of strings, month, day, and the day with month together, define the variables as follows.

  • To store the value of the current date as a list of strings, define a variable as: Variable Name: “strList”, Data Type: select “string”, and check “List” This defines the data type as a list of strings. This variable will store the value of the current date as a list of strings. The format of the date and time in Langstack applications is “YYYY-MM-DD hh:mm:ss” or “YYYY-MM-DDThh:mm:ss.”

  • To store the value for the month in the current date, define a variable as: Variable Name: “strMonth”, Data Type: “string”

  • To store the value for the day in the current date, define a variable as: Variable Name: “strDay”, Data Type: “string”

  • To store the value for the day and month together from the current date, define a variable as: Variable Name: “strDayMonth”, Data Type: “string” This variable will contain the value for the day and month in the current date.

  • To define the criteria for the trigger, go to the “Criteria” tab. To add a Criteria bar, click the (+) button. Define the Criteria bar to verify if the value in the Join_Date field of the entity is present.

    1. Select Source as Variables>Created_Record>Join_Date. It will display as “Created_Record.Join_Date”. This variable contains the value of the Join_Date field for the newly created record.

    2. Select operator as “Is Set”.

  • To define Actions if the criteria return True, go to the Code tab>On True section. Add an Action by clicking the (+) button.

  • To split the current date based on the delimiter to result in a list of strings, define the first Action as follows:

    1. Select Action “Split string”. This Action is for splitting the string into a list of items.

    2. Select Target variable as “strList”. The value of the list of strings will be stored in this variable.

    3. Select Source string as Variables>Created_Record>Join_Date>toString(). It will display as "Created_Record.Join_Date.toString()". This contains the value of the created record join date which is first converted to string and added as the source.

    4. Type Delimiter as “-” and press Enter. It will be added in a blue bubble. This variable defines that the string is split based on the encounter of the “-”. We have the year as a separate string and a month as a separate string, however, the day is still combined with the time. The value of the day will be separated from the time later in the exercise.

  • To get an item from the list of strings, add the second Action and define it as follows:

    1. Select Action as “Get List item”.

    2. Select Target variable as “strMonth”. Select Source list as Variables>strList, which displays as “strList”. The current month's value is taken from the variable “strList”.

    3. Type Index value as “1” and press Enter. This is the index position of the item to be taken from the string. In this case, the month is at 1. [“YYYY”, “MM”, “DD hh:mm:ss”] = [“(index value=0)”, “(index value=1)”, “(index value=2)”]

    4. Select the “As Copy” checkbox. This defines that the Target Value will only contain a pointer to the index value and not hold the actual value of it.

  • To update the value of the day in a variable, add the third Action and define it as follows:

    1. Select Action as “Update Variable”. This Action updates a variable from a source.

    2. Select Target variable as “strDay”. At this point, after the split based on the delimiter “-”, the last part of the string contains the value of the day and time.

    3. Select Value as Variables>strList>getLast(), which displays as “strList.getLast()”. This is the value of the last index position in the list of strings. This Action updates the last part of the list of strings into the variable “strDay” i.e. [“YYYY”, “MM”, “DD hh:mm:ss”]

  • To separate the value of day from the time, add the fourth Action and define it as follows:

    1. Select Action as “Split string”. This Action is for splitting the string into a list of items.

    2. Select Target variable as “strList”. The value of the list of strings will be stored in this variable.

    3. Select Source string as Variables>strDay, which displays as “strDay”. The value of string in this variable will be split into a list of strings.

    4. Type Delimiter as “(space)” and press Enter. It will be added in a blue bubble. This variable defines that the string is split based on the encounter of the “(space)”. In this Action, the current date will be split based on the delimiter “ “ (space) and will result in a list of strings i.e. from the list [“YYYY”, “MM”, “DD hh:mm:ss”], the last item will be split into another list: [“DD”, “hh:mm:ss”]. This results in the value of day in the first index position, and the time in the second index position.

  • To update the value of the day from the list of string (day and time), add the fifth Action and define it as follows:

    1. Select Action as “Update Variable”. This Action updates a variable from a source.

    2. Select Target variable as “strDay”. The value of the Day in the list of strings will be stored in this variable.

    3. Select Value as Variables>strList>getFirst(). It displays as strList.getFirst(). The first value in the list will be the source. [“DD”, “hh:mm:ss”]

  • To update the values of day and month in a variable, add the sixth Action and define it as follows:

    1. Select Action as “Update Variable”. This Action updates a variable.

    2. Select Target variable as “strDayMonth”. This variable contains the value of the day and month concatenated.

    3. In the Value, first select Variables>strDay and press Enter followed by select Variables>strMonth and pressing Enter. Each variable will be displayed in a white bubble. This Action updates the variables of strDay and strMonth into the variable “strDayMonth”.

  • To update the day and month values stored in strDayMonth into the DayMonthJoinDate field of the new record, add the seventh Action and define it as follows:

    1. Select Action as “Update Variable”. This Action updates a variable.

    2. Select Target variable as Created_Record>DayMonthJoinDate. This is displayed as “Created_Record.DayMonthJoinDate”.

    3. In the Value, select Variables>strDayMonth.” It is displayed as “strDayMonth”. This Action updates the created record with the value of day and month joined together.

  • Finally, the sequence of Actions will look as per the image below:

  • To save the entity, click the [Save] button.

  • To close the Entity, click the [Close] button.

  • To test the trigger, create a new record by clicking the [+ Record] button.

  • Create a new record with no value in the DayMonthJoinDate. To save the record, click the [Save] button. The displayed record will have the DayMonthJoinDate value updated as per the date in the Join_Date field. If there is no Join_Date value added, the system automatically updates the value in the Join_Date to be “1970-01-01” and the same will be updated in the DayMonthJoinDate field.

💡
📕