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 - If agreement is cancelled , it should auto-delete after 5 days of cancelling. and Warning sign will be displayed on the screen after agreement is cancelled.

Write a trigger - If an agreement is canceled, it should auto-delete after 5 days of canceling. and a Warning sign will be displayed on the screen after an agreement is canceled.
Best Answer chosen by Ganta Suresh
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Go to setup-> Flow-> New flow and select record triggered flow and select object as Agreement object.

User-added image
In the above screenshot instead of Active field select status of agreemnt and select value as Cancelled.

Now select the scheduled path by clicking in start element as shoiwn below.

User-added imageNow provide all the details as shown below. Instead of Account updated selet Agreement updated.

User-added imageNow onclick Plus symbol as shown below and select delete record option from the available options and provide the details as shown below.

User-added imageUser-added image

Now save the flow and click on activate button .

When a record is edited and put as Cancelled then this flow will delete that record after 5 days.

Let me know if you face any issues.

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

Thanks,

All Answers

Ganta SureshGanta Suresh
SaiPraveen.Any idea on this?
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Suresh,

Even for the deletion of the record after 5 days you may have to go with similar batch or scheduled flow or workflow. By using trigger you cannot set future actions as I said in my eariler question.

Displaying the warning sign means do you want any text displayed on the record once it is Cancelled showing that the agreement is already cancelled?

Thanks,
 
Ganta SureshGanta Suresh
@SaiPraveen we are showing a warning message on the screen that the canceled agreement was deleted -
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Suresh,

As per your requirement the record should deleted 5 days after cancellation .  So how can we show on screen that "canceled agreement was deleted" after 5 days?

Ideally what I guess it we should show on the screen saying that this agreement is cancelled and will be deleted in 5 days. Can you confirm on it.

Let me know if you face any issues.

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

Thanks,
Ganta SureshGanta Suresh
@SaiPraveen    Please show me a sample example of how can we do workflow. for
my case If an agreement is canceled, it should auto-delete after 5 days of canceling.
                 A warning sign will be displayed on the screen after an agreement is canceled
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Suresh,

A small correction to my previous answer. This may not be able to do with workflow because we cannot delete record using workflow

We have to do it with flow  . Are you okay with it

Thanks,
 
Ganta SureshGanta Suresh
@SaiPraveen  Give me the sample .. How can we do this using FLOW I am okay with it.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Go to setup-> Flow-> New flow and select record triggered flow and select object as Agreement object.

User-added image
In the above screenshot instead of Active field select status of agreemnt and select value as Cancelled.

Now select the scheduled path by clicking in start element as shoiwn below.

User-added imageNow provide all the details as shown below. Instead of Account updated selet Agreement updated.

User-added imageNow onclick Plus symbol as shown below and select delete record option from the available options and provide the details as shown below.

User-added imageUser-added image

Now save the flow and click on activate button .

When a record is edited and put as Cancelled then this flow will delete that record after 5 days.

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 will let you know you in case need any help..!