function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jyothi NimmakayalaJyothi Nimmakayala 

Flow trigger to compare two record dates to send email

When a contact attends seminars first time, an email should be sent . Same contact attending seminar within 60 days from intial email sent, no email needs to sent out. After 60 days , if same contact attended new seminar , send a new email. 
Seminar(Custom object) is a related list under contact . 
I think flow trigger/apex trigger is the way to go in comparing date of last email sent . But i am completely new to flow triggers. Can anyone please assist.
Fields avaliable in Seminar object 
Seminar_Status__c     Picklist
Contact__c                  Lookup(Contact)
Lead__c                       Lookup(Lead)

Criteria: Seminar Status= "Attended" and Contact<>NULL

Thank you 
Prakhar Saxena 19Prakhar Saxena 19
Hi Jyothi,

You can achieve this by using Process Builder. However, you will have to add one more field on the Seminar object which captures the Sent Email Date.

Intitially, the Email Sent Date field's value will be null.

The first criteria checks if Seminar's Contact__c field is not null and Email_Sent_Date__c field is null. If true, it performs two Immediate Actions of sending Email and Updating Email_Sent_Date__c field to Today's Date.

The second criteria checks if Seminar's Contact__c field is not null, Email_Sent_Date__c field is not null and Email_Sent_Date__c is less than (Today's Date - 60). If true, it again performs the same two Immediate Actions of sending Email and Updating Email_Sent_Date__c field to Today's Date.
User-added image
User-added imageUser-added image

User-added image
Jyothi NimmakayalaJyothi Nimmakayala
Hi Prakhar,

First and foremost, i would like to thank you for taking time and responding to my question. 

I did try the suggested solution and noticed that email sent date should be on the contact object instead of seminar object, since contact remains the same while seminar changes. If email sent field is on seminar object, every time a contact attends seminar, inital email field will be null and email will be triggered. But based on my requirement, i need the email to be send only the first time seminar is attended.
Example: Seminar no : S-001, S-002, S-003 and contact :Mr.  Test seminar
Mr. Test seminar attended S-001 today , S-002 tomorrow and seminar S-003 after 60 days from S-001
I want email sent out to Mr.Test seminar when attended S-001 and no emails be sent after the first seminar S-001 attended . So email should be triggered when S-002 seminar attended since it's in the block out period. After 60 days, when Mr. Test Seminar attends a new seminar S-003 , yes email can be trigerred and so forth.

 
Prakhar Saxena 19Prakhar Saxena 19
Okay, that's fine.

You can keep the Email_Sent_Date__c field on the Contact Object. You will just have to change the reference in the Process Builder. Rest of the things remain same.

Instead of using [Seminar__c].Email_Sent_Date__c field in the builder, create Email_Sent_Date__c field on the Contact object and refer it like:

[Seminar__c].Contact__c.Email_Sent_Date__c at all places in the builder.

Let me know if there are any issues.