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
Ganta SureshGanta Suresh 

write a trigger - Agreement will auto expire when expiration date is met

Please help me..!

Write a trigger - when an agreement will auto-expire when the expiration date is met an alert will be sent 3 months before the expiration date.

Best Answer chosen by Ganta Suresh
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

I am creating it on Account object as I dont have Agrreemnt object. 

Go to setup-> Workflow Rules-> new-> select object as Agreement.

User-added imageNow click on save and next and in next screen click on button as shown below.

User-added image
Add 90 days and select after expiration date as below.
User-added image
Now click on new email alert as shown below.

User-added image
and then select the email alert and other mandatory values and save it and then activate the worjflow rule.

If we use scheduled flow the it will run every day and checks which will expire in 90 days and send the emails.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Ganta,

Do you want trigger or you are fine with Flow? 

I hope agreement is custom object and you want 3 monthe before expoiratoon date you need to send an email. But with trigger this may not be possible because trigger will only fire when record is created ot updated but here with out updation of record the email should be triggered before 3 months of exipiration date.

Ideally this should be scheduled triggerv flow or Batch apex.

Thanks,
 
Ganta SureshGanta Suresh
@sai Praveen I want the trigger and Yes Agreement is a custom objectUser-added image
Ganta SureshGanta Suresh
@saiPraveen
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Suresh,

As said earlier you cannot schedule an action to send 3 months before expiration using trigger. 

You can only do with batch class or Sceduled Flow or time dependant workflow
 

Let me know if you face any issues.

 

If this solution helps, Please mark it as best answer.

 

Thanks,

Ganta SureshGanta Suresh
@SaiPraveen Show me one example how can we perform Scheduled Flow or time dependant workflow -
using my case -  when an agreement will auto-expire when the expiration date is met an alert will be sent 3 months before the expiration date.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

I am creating it on Account object as I dont have Agrreemnt object. 

Go to setup-> Workflow Rules-> new-> select object as Agreement.

User-added imageNow click on save and next and in next screen click on button as shown below.

User-added image
Add 90 days and select after expiration date as below.
User-added image
Now click on new email alert as shown below.

User-added image
and then select the email alert and other mandatory values and save it and then activate the worjflow rule.

If we use scheduled flow the it will run every day and checks which will expire in 90 days and send the emails.

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
This was selected as the best answer
Ganta SureshGanta Suresh
@SaiPraveen Thank you so much ...will try this one and let you know if I need any help. 
Ganta SureshGanta Suresh
@saiPraveen Could you please help me with this case give me sample with pics - when an agreement will auto-expire when the expiration date is met an alert will be sent 3 months before the expiration date  --  On FLOW BUILDER
Ganta SureshGanta Suresh
@SaiPraveen Could you please help me with this case give me a sample with pics - when an agreement will auto-expire when the expiration date is met an alert will be sent 3 months before the expiration date  --  On FLOW BUILDER
Ganta SureshGanta Suresh
@SaiPraveen Could you please help me with this case give me a sample with pics - when an agreement will auto-expire when the expiration date is met an alert will be sent 3 months before the expiration date  --  On FLOW BUILDER