+ Start a Discussion
Guru Vemuru 1Guru Vemuru 1 

How to send email alert only on week day not in weekends?

Hi all,

I have a requirement to sent email alert to lead owner  and conditions are like
  1. Alert will go to lead owner after 2 hours from lead created time
  2. Lead owner will get mail only Week days and not in week ends
Guru Vemuru 1Guru Vemuru 1
I created Time base work flow there i given (TimeValue(Created Date) =2 Hrs). It working

How can i find out day is Sat and Sun.
 Leads which are coming on sat ansd sun. we have to send mail alert on Monday morning 11am.
how to do it
 
Salesforce DeveloperSalesforce Developer
No any straight forward solution, create a custom field and set the field with the date on which email should be sent.
Guru Vemuru 1Guru Vemuru 1
hi,
I found the created day is it sun, mon..... and according to that by giving condition I can able send mail.

Now the problem is the leads which are created in sun and sat. I have to notify on Monday morning 11 AM.
How can I do it
Tunde OdutolaTunde Odutola
Hi Guru,
I modified a formula that i found on the iner net and have used before but I have tested for your case.

Try 
CASE(
MOD( date - DATE( 1900, 1, 7 ), 7 ),
6, (Created Date) + 59/24 days),
7, (Created Date) + 35/24 days),
(TimeValue(Created Date) =2 Hrs)
)
The formula finds the day of the week of the date field value. If the date is 6, Saturday you add 2 days and 11 hours, if it is 7, Sunday add an extra day and 11 hours, you may need to take account of your time zone relative to GMT and adjust the hours accordingly.
 
Jon Raney 2Jon Raney 2
For Posterity I believe Salesforce Developer's comment is correct now that WEEKDAY() is a legit function is SF since 2018.
  • Use the weekday(datefield) function and set that as a formula and use the formula field as criteria rather than as time trigger. 
  • Let Salesforce do the GMT dates natively based on the normal time trigger
  • Presuming the Date field is Date/Time field, wrap that with DATEVALUE formula
  • Replicate the email alert into 2 Workflow rule/alerts with the 2 different criteria date=, date <>
    • Alert 1 criteria for Lead Create Date formula field: WEEKDAY(DATEVALUE(CreatedDate ))= 1)) || (DATEVALUE(CreatedDate ))= 7)) && (whatever other criteria you have)
    • Alert 2 criteria for Lead Create Date formula field: : Same as above, swapping <>