How to create a condition in the flow to compare current date with a date in the catalog variable.

somasekharK
Tera Contributor

I have requirement to develop the flow like, after creating the catalog task for a catalog request, 

If the catalog task still open, we need to check the current date with a date value from a date variable in the catalog from. If current date is grater than the date value in the form variable then I have to send a mail. I am unable to implement this logic, up to the task closed complete daily we need to send a mail by developing above condition. 

1 ACCEPTED SOLUTION

Badrinarayan
Tera Guru

Hi @somasekharK


I have Implemented this Logic Previously , It was working fine for me 

 

First create a Flow , 

 

1. Trigger Condition is Daily 

 Screenshot 2024-09-16 at 1.46.23 PM.png

 

2. Create a Flow Variable by Clicking the 3Dots[...]  Icon present on the top right flow

select the flow variables option from that -> next create a Flow Variable with Name , Type , & Label.

 

Screenshot 2024-09-16 at 1.50.31 PM.png

 

3. In the Actions , 

 Create a Set Flow Variables from flow logic 

Screenshot 2024-09-16 at 1.51.45 PM.png

 

 

var today = new GlideDate();
return today;

 

 

 

4.LookUp Records:

  1. LookUp Records Action:

    • In the flow designer, add the LookUp Records action.
  2. Select the Table:

    • Choose the table where you want to apply the logic. For example, if you're working with a custom table, select that table from the list.
  3. Add Conditions (if necessary):

    • You can define conditions to filter records from the table (e.g., only retrieving records where certain fields match specific values).
  4. Proceed with Flow Logic:

    • Once you've selected the table and added the conditions, you can continue with your flow actions, such as For Each, sending notifications, or updating records.

Screenshot 2024-09-16 at 1.57.00 PM.png

 

5. For Each Item Lookup Records -> Select Table Records 

6.If Condition

 Each loop to iterate over the records and have an If condition with the label "Date Before Current Date" that compares the "Date" field of the records to a flow variable called "current."

  • Condition: For Each Item Record > Date is before Flow Variables > current
  • The condition will evaluate true if the record's date is earlier than the current date

Screenshot 2024-09-16 at 6.20.08 PM.png

7.Send Notification:

Once the condition is met (i.e., the date is before the current date), you can send a notification to the desired recipients. Here's how you can do that:

  1. Add a Notification Action:

    • In the flow designer, after the If condition, add the Send Notification action.
  2. Define the Recipient(s):

    • Specify whom you want to send the notification to. You can choose users, groups, or use dynamic fields based on your flow logic (e.g., the user from the record being processed).
  3. Compose the Message:

    • Add the subject and message body.
    • You can use variables from the flow or record to dynamically populate the message (e.g., using the date or other fields from the record).

 

My Overall Flow

Screenshot 2024-09-16 at 6.22.58 PM.png

 

Customise As per your Requirement

 

Please mark this solution as helpful and accept it if your issue has been resolved. Let me know if you need any further assistance!


Thanks Regards 

Badrinarayan

 

 

View solution in original post

4 REPLIES 4

Mani A
Tera Guru

var currentDate = new GlideDateTime();

var formDate = new GlideDateTime(current.variables.date_variable); // Adjust variable name

 

if (currentDate.getDisplayValue() > formDate.getDisplayValue()) {

    // Proceed to send email

}

 

Which flow action can I use to develop this script.

create custom action and pass inputs ( date variable) ..and in that use script

Badrinarayan
Tera Guru

Hi @somasekharK


I have Implemented this Logic Previously , It was working fine for me 

 

First create a Flow , 

 

1. Trigger Condition is Daily 

 Screenshot 2024-09-16 at 1.46.23 PM.png

 

2. Create a Flow Variable by Clicking the 3Dots[...]  Icon present on the top right flow

select the flow variables option from that -> next create a Flow Variable with Name , Type , & Label.

 

Screenshot 2024-09-16 at 1.50.31 PM.png

 

3. In the Actions , 

 Create a Set Flow Variables from flow logic 

Screenshot 2024-09-16 at 1.51.45 PM.png

 

 

var today = new GlideDate();
return today;

 

 

 

4.LookUp Records:

  1. LookUp Records Action:

    • In the flow designer, add the LookUp Records action.
  2. Select the Table:

    • Choose the table where you want to apply the logic. For example, if you're working with a custom table, select that table from the list.
  3. Add Conditions (if necessary):

    • You can define conditions to filter records from the table (e.g., only retrieving records where certain fields match specific values).
  4. Proceed with Flow Logic:

    • Once you've selected the table and added the conditions, you can continue with your flow actions, such as For Each, sending notifications, or updating records.

Screenshot 2024-09-16 at 1.57.00 PM.png

 

5. For Each Item Lookup Records -> Select Table Records 

6.If Condition

 Each loop to iterate over the records and have an If condition with the label "Date Before Current Date" that compares the "Date" field of the records to a flow variable called "current."

  • Condition: For Each Item Record > Date is before Flow Variables > current
  • The condition will evaluate true if the record's date is earlier than the current date

Screenshot 2024-09-16 at 6.20.08 PM.png

7.Send Notification:

Once the condition is met (i.e., the date is before the current date), you can send a notification to the desired recipients. Here's how you can do that:

  1. Add a Notification Action:

    • In the flow designer, after the If condition, add the Send Notification action.
  2. Define the Recipient(s):

    • Specify whom you want to send the notification to. You can choose users, groups, or use dynamic fields based on your flow logic (e.g., the user from the record being processed).
  3. Compose the Message:

    • Add the subject and message body.
    • You can use variables from the flow or record to dynamically populate the message (e.g., using the date or other fields from the record).

 

My Overall Flow

Screenshot 2024-09-16 at 6.22.58 PM.png

 

Customise As per your Requirement

 

Please mark this solution as helpful and accept it if your issue has been resolved. Let me know if you need any further assistance!


Thanks Regards 

Badrinarayan