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
Julio SJulio S 

Send an email once a field hasn't been updated for a numbers of days.

Hello,

I have a field named, Last_payment__c (date field), is there any possibility to trigger an email if that mentioned field hasn't been updated for a numbers of days? Lets say 7 days. Please advise.

Thanks
Vivek S 42Vivek S 42
Hi Julio, 

You can create a formula field with return type as Check box holding the AND condition of Date with in the 7 days and isChanged of that field you want to track.  And write a batch and schedule it every day based on that checkbox. Which will scan the records for which that checkbox is checked and Sends out an email. 

Thanks, 
Vivek S
Julio SJulio S
Thanks Vivek, would you mind showing me how its done, if possible only? It's been a while since I have last used salesforce.
GauravGargGauravGarg
Hi Julio,

Please write workflow rule for this.
1. Condition Not(Ischanged(field_Name))
2. Time Triggered Email Alert.
3. Email alert time +7 days.
4. Set Email body
I hope this will work for you. 

Let me know if you need to have a screensharing session to complete this task. 

Thanks,
Gaurav
Skype: gaurav62990
Email: gauravgarg.nmims@gmail.com
Pradeep SinghPradeep Singh
Hi Julio and Gaurav,
This will not work as the record can be updated 2 days after and it checks the condiion and will fire the email after 7 days. But in Julio's case, the field should not have been updated from the last 7 days, then email should be sent.

In this case, you have to activate Field History tracking for the particular field and write code(schedule batch/trigger whatever suits your requirement) which queries the record from the sObjectHistory object and you can check if there is any entry for that field for the last 7 days and send an email.
Refer image below for the records of the AccountHistory records for Industry field.

User-added image
 
GauravGargGauravGarg
Hi Pradeep, 

If records get updated after 2 days, the email should fire after 7 days of last modification i.e. 2 + 7 =  9 days. Workflow will definetly work on this. Otherwise Batch process (scheduler) will work which can be scheduled for daily basis to check lastmodifieddate > 7 days

Hope this understand. 

Thanks,
Gaurav
Pradeep SinghPradeep Singh
Hi,
Last modified date will not work as well as this will not give you the last modified date of any field, it gives you the last modified date of the record. According to the question, mail should be send only when a particuar field(not record) has not been update since last 7 days.

Hope this will help
GauravGargGauravGarg
Oh my Apologies.  In this scenario we can use a workaround.
 
Write 2 workflow:

First Workflow to determine if the field has been updated in last 7 days.

	1. Create a Date/time field lets say "Last_Payment_Made__c"
	2. Write workflow to update the value of "Last_Payment_Made__c" if value of field "Payment__c" is updated. 
		Formula:

		IsChanged(Payment__c)

	3. Create a field update to update "Last_Payment_Made__c" to "Now()".

Second Workflow to determine when the field "Last_Payment_Made__c" was updated. 

	1. Condition Not(Ischanged(Last_Payment_Made__c))
	2. Time Triggered Email Alert.
	3. Email alert time +7 days.
	4. Set Email body


We should avoid code until this is last approach, else salesforce team won't support if anything fails. 

Thanks,​
Gaurav
Skype: gaurav62990

Pradeep SinghPradeep Singh
Gaurav, this won't work too as you cannot define the sequence of the workflows.So which one runs first is not fixed.
Julio SJulio S
Thanks for all your help guys. I've created a Process builder, and it would seem to appear that its triggering the email okay, just need to polish some of its components.