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 Process
  4. Exercise: Customer Anniversary Email Activity

Step 1: Check if the join date matches the current date

PreviousExercise: Customer Anniversary Email ActivityNextStep 2: Test the Process

Last updated 2 years ago

To check if the join date matches the current date, follow the steps below.

  • To go to the Process template, select “Process” under the Background processes menu on the left side panel.

  • In the Background processes>Process tab, click the [+ Process] button.

  • To label the Process and enable it, go to the “Details” tab. In the “Details” tab:

    1. Enter the Process name as “CustomerJoinDateAnniversaryNotification”.

    2. Optionally enter the description for the Process.

    3. Ensure the Process is enabled.

  • To disallow multiple requests simultaneously, leave the toggle button enabled for “skip execution while in progress”. Enabling this toggle button defines that the execution of this Process will be skipped when there is one already in progress.

  • The default value for Process execution is selected as “Immediate”. For this exercise, keep it as is.

  • To define the shared variables, go to the “Variables” tab. This tab consists of the shared variable “StartupParameters” with the data type “List”.

  • To add a variable, click the [+ Variable] button.

  • Add and define (2) shared variables:

    1. To have a variable to hold the day and month of the current date, define the first variable as follows: Variable Name: ”strDayMonthToday”, Data Type: “string”.

    2. To have a variable to hold the current date, define the second variable as follows: Variable Name: “currentDate”, Data Type: “DateTime” and initialize it to “DateTime.Now()” (Navigate to Functions>DateTime>Now).

  • To create a new Target Entity, go to the “Target Entities” tab and click [+ Target Entity]. This Target entity is where the Process will update the records.

  • To define the target entity, select the “Target Entity” from the drop-down menu as “UserName_Acc_Activities”.

  • To add the sequence of actions to check if the current date matches the customer's join date, go to the “Code” tab. To create a new “Action box”, click the [+ Action box] button.

  • To calculate the day and month of today, label the Action box as “Calculate DayMonth of today”. This is the first “Action box” in which the value for the “DayMonthJoinDate” (field in the entity “UserName_Acc_customer”) for the current day will be evaluated and stored in the record to be updated.

  • To define variables for the actions in this Action box, go to the Action box>Variables tab. To create a new variable, click the [+ Variable] button. Create three (3) variables.

  • To store the value of the current date as a string, define a variable as follows: Variable Name: “current_daymonth”, Data Type: select “string”.

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

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

  • To add an action, go to the Action box>Code tab of the “Action box” and click the (+) button.

  • To update the variable with the “current_day” with the day's value in the current date, define the added Action as follows:

    1. Select Action as “Update Variable”.

    2. Select the Target variable as “current_day”.

    3. Select Value by navigating the dropdown Functions>DateTime>Now()>Day()>toString(). It will display as “DateTime.Now().Day().toString()”. The current day's value is first converted to string and then updated to the variable “current_day”.

  • To update the variable with the “current_month” with the month's value in the current date, add and define another Action as follows:

    1. Select Action as “Update Variable”.

    2. Select the Target variable as “current_month”.

    3. Select Value by navigating the dropdown Functions>DateTime>Now()>Month()>toString(). It will display as “DateTime.Now().Month().toString()”. The current month's value is first converted to string and then updated to the variable “current_month”.

  • To add a zero in case the month is of 1 digit, add and define an Action as follows:

    1. Select Action as “Condition action”.

    2. Enter the label as “if month is 1 digit, add a zero”.

  • To check if the length of the month's value is equal to 1, add and define a Criteria bar as follows:

    1. Select Source as Variables>current_month>length(). It displays as current_month.length().

    2. Select Operator as “Is Equal”.

    3. Enter Value as ‘1’ and press Enter.

  • If the Criteria is returned as true, define an Action in the Code tab>On True section as follows:

    1. Select Action as “Update Variable”.

    2. Select the Target variable as “current_month”.

    3. Define Source as follows:

      1. In the Source, type ‘0’ without quotes and press Enter.

      2. Navigate the dropdown and select Variables>current_month.

  • To update the variable with the “current_daymonth” with the month's value in the current date, add another Action after Condition action and define it as follows:

    1. Select Action as “Update Variable”.

    2. Select the Target variable to be “current_daymonth”.

    3. Select Value as follows:

      1. Navigate and select the “current_day” variable.

      2. Navigate and select the “current_month” variable.

  • To traverse the entity “UserName_Acc_customers” for comparing the values of the customer's join date with the current date, define the Action as follows:

    1. Select Action as “Traverse Entity”. This action will traverse an entity.

    2. Select entity “UserName_Acc_customers”. This entity will be traversed.

    3. In the field “Treat element in the list as”, the variable named “item” is automatically created and populated. This item contains the value of each element in the list of the records read from the “UserName_Acc_customers” entity.

  • To set up the criteria for Traverse Entity selected as “UserName_Acc_customers”, click the "Criteria Setup" icon.

  • To define settings for the traverse such that the entity can be traversed in order by the “DayMonthJoinDate” in the entity in ascending manner, set the criteria as follows:

    1. Order By: “Join_Date”. This defines that the records to be traversed will be ordered by the Join_Date field of the entity.

    2. Ascending: the records to be traversed will be ordered in an ascending manner, i.e., the joining date of the oldest value will be displayed first.

  • To add a Match Key, click the [+ Match key] button.

  • To define a Match key:

    1. Select the field as “DayMonthJoinDate”.

    2. Select Variables>current_daymonth. It displays as “current_daymonth”. The field “DayMonthJoinDate” will be matched with the variable “current_daymonth”. This match key defines that only those records will be traversed in which the DayMonthJoinDate's value is the same as the values of day and month in the current date.

    3. To save the settings, click the [Save] button.

  • To define Variables for Actions in the Traverse Entity Action, go to Variables. A variable “item” is already created.

  • Add two (2) more Variables.

  • To store the value for the existing anniversary, define the first variable as follows:

    1. Variable Name: “existing_anniversary”

    2. Data Type: “UserName_Acc_Activities”

  • To send a response, define the second variable as follows:

    1. Variable Name: “new_anniversary”

    2. Data Type: “UserName_Acc_Activities”

  • To define the actions for the Traverse Entity Action, go to the Code tab and add a new Action.

  • To find the first item in the list of entity records, define the first Action as follows:

    1. Select Action as “Find first List item”

    2. Select Target variable as “existing_anniversary”

    3. Select Source List as Variables>item>Customer_Activities. It displays as “item.Customer_Activities”.

  • To define the criteria for the “Find first List item” Action, click on the “Setup criteria” icon.

  • Based on the Filter Settings, if a record for an Anniversary is already created for a customer and the record creation date is the current date, then that record (in the variable “itemActivities”) will be updated into the variable “JoinDateAnniversaryList”. If by the end of this traverse, “JoinDateAnniversaryList” is empty, a new record will need to be created. If it has any record, the new record will not be created. To set up the Filter Settings, add two (2) Criteria bars by clicking the (+) button.

  • To check if the Activity Type in the traversed record is equal to “Anniversary”, define the first Criteria bar as follows:

    1. Select item>Activity_Type. It displays as “item.Activity_Type”.

    2. Select Operator as “Is Equal”.

    3. Type the text “Anniversary” and press Enter. The text displays in a blue bubble. This Criteria bar checks if the value of the “Activity_Type” in the traversed record matches the type “Anniversary”.

  • To check if the Activity_Type in the traversed record is created today, define the second Criteria bar as follows:

    1. Select item>Activity_DateTime. It displays as “item.Activity_DateTime”.

    2. Select Operator as “Is today”.

  • To set the criteria such that both the Criteria bars must return “True”, keep the logical operator as “AND”. If both of the Criteria bars return “True”, no new record will be created. To save the Filter Settings, click the [Save] button.

  • Add a new action in the Traverse entity action and define it as follows:

    1. Select Action as “Condition action”.

    2. Enter the description as “if the anniversary exists, skip the customer”.

  • To check if the value for the “existing_anniversary” is received, in the Criteria tab add a new Criteria bar:

    1. Select Source as Variables>existing_anniversary. It displays as “existing_anniversary”.

    2. Select the Operator as “Is Set”.

  • To define the action if the criteria is True, in the Code tab>On True section add an Action “Continue List Traverse”.

  • To add a group of actions for assigning values to the record fields, a new Action after the Condition action and define it as follows:

    1. Select Action as “Group action”.

    2. Enter the description as “updating the anniversary fields”.

  • In this Group action, the actions will be configured to update the values of the fields of the target entity “UserName_Acc_Activities” through the variable “new_anniversary”. Add six (6) actions.

  • To update the variable “new_anniversary” with a value for the field “Activity_AssignedTo” in the entity, define the first Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target variable as new_anniversary>Activity_AssignedTo and press Enter. It will display as “new_anniversary.Activity_AssignedTo”.

    3. Enter Value as “sales team” (without quotes) as constant text. This text will be displayed in the field for the record.

  • To update the variable “new_anniversary” with a value for the field “Activity_Type” in the entity, define the second Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target variable as new_anniversary>Activity_Type and press Enter. It will display as “new_anniversary.Activity_Type”.

    3. Add the Value as “Anniversary” (without quotes) and press Enter. This text will be displayed in the field for the record.

  • To update the variable “new_anniversary” with a value for the field “Activity_CreatedBy” in the entity, define the third Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target Variable as new_anniversary>Activity_CreatedBy and press Enter. It will display as “new_anniversary.Activity_CreatedBy”.

    3. Enter Value as “anniversary process” (without quotes) and press Enter. This text will be displayed in the field for the record.

  • To update the variable “new_anniversary” with a value for the field “Activity_Description” in the entity, define the fourth Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target variable as new_anniversary>Activity_Description. It will display as “new_anniversary.Activity_Description”.

    3. Add the Value as “this is the anniversary of the customer’s joining date.” (without quotes) and press Enter. This text will be displayed in the field for the record.

  • To update the variable “new_anniversary” with a value for the field “Activity_DateTime” in the entity, define the fifth Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target variable as new_anniversary>Activity_DateTime. It will display as “new_anniversary.Activity_DateTime”.

    3. Select the Value as Functions>DateTime>Now(). It will display as “DateTime.Now()”. This will update the field for the record with current date information.

  • To update the variable “new_anniversary” with a value for the field “Customer_ID” in the entity, define the sixth Action as follows:

    1. Select Action as “Update Variable”.

    2. Select Target variable as new_anniversary>Customer_ID and press Enter. It will display as “new_anniversary.Customer_ID”.

    3. Select the Value as Variables>item>Customer_ID. It will display as “item.Customer_ID”.

  • The Group action will look as per the image below.

  • To create a new record, add a new Action after the Group action. To update the values of the fields updated in the variable (by the first six actions) into a variable createRecord and create the record in the target entity, define the Action as follows:

    1. Select Action as “Create Entity record”. This action creates a new record in the Target Entity and its related entities.

    2. Add a new variable by clicking [+] and name it “anniversary_response”. To save this variable, click the [Save] button. This variable will be the data type JXPResponse variable and will display the success or failure of the record creation.

    3. Select Entity variable as “new_anniversary”. The information of the fields stored in this variable will be populated in the newly created record in the target entity.

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

  • To publish the Process, click the [Publish] button.

Triggering Flow

To trigger a flow, add a new action after "Create Entity record" and follow the steps below:

  1. To check if the record is created successfully, add and define an Action as follows:

    1. Select Action as “Condition action”.

    2. Enter the description as “check if creation is successful”.

  1. To check if the error code is equal to “0”, in the Criteria tab, add a Criteria bar as follows:

    1. Select Variables>anniversary_response>errorcode. It displays as “anniversary_response.errorcode”.

    2. Select Operator as “Is Equal”.

    3. Type the Integer value as “0” and press Enter. The text displays in a blue bubble.

  1. To configure the Flow “CustomerActivityCreated” to be triggered when this Process is executed, in the Code tab>On True section, add and define an Action as follows:

    1. Select Action as “Trigger Flow”.

    2. Select Flow as “CustomerActivityCreated”.

    3. Select Entity variable as Variables>new_anniversary. It is displayed as “new_anniversary”.

    4. Details Json field is empty.

  1. To display the Activity_ID of the created record on the Test Console, add the last Action and define it as follows:

    1. Select Action as “Display on test console”.

    2. Select Variables>new_anniversary>Activity_ID. It will display as “new_anniversary.Activity_ID”.

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

  • To publish the Process, click the [Publish] button.

For this exercise, skip the upcoming steps with the “Trigger Flow” action as these are a part of exercises in Introduction to Flows & Flow components. Save and publish the Process, and proceed to section.

💡
📕
Test the Process