You need to sign in to do that
Don't have an account?
Birthday reminder
I am creating a workflowto assign a task for the contact owner before 7 days on contact's birthday.
I have created a formula field to calculate contacts next birthdate from Birthdate field using the following formula
IF(MONTH(Birthdate)>MONTH(TODAY()),DATE(YEAR(TODAY()),MONTH(Birthdate),DAY(Birthdate)),
IF(MONTH(Birthdate)<MONTH(TODAY()),DATE(YEAR(TODAY())+1,MONTH(Birthdate),DAY(Birthdate)),
IF(DAY(Birthdate) >=
(DAY(TODAY())),DATE(YEAR(TODAY()),MONTH(Birthdate),DAY(Birthdate)),
DATE(YEAR(TODAY())+1,MONTH(Birthdate),DAY(Birthdate)))))
I have assigned a task,now how do i test this?
check the code in my next post it is 100% working
global class memberBirthdayBatch implements Database.batchable<contact>
{
global Iterable<contact> start(Database.batchableContext info)
{
System.debug('Start method');
return new callMemberIterable();
}
global void execute(Database.batchableContext info, List<contact> scope)
{
List<contact> memsToUpdate = new List<contact>();
System.debug('++++++++++++++++++++++Member list size is++++++++++++++++++++++++++ ' + scope.size());
for(contact m : scope)
{
Date myDate = date.today();
Integer todayDy = myDate.day();
Integer todayMon = myDate.month();
Integer dy = m.Birthdate.day();
Integer mon = m.Birthdate.month();
System.debug('++++++++++++++++++++++++++Day is ++++++++++++++++++++++++++' + m.Birthdate.day());
if(todayDy == dy && todayMon == mon)
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddresses = new List<String>();
toAddresses.add(m.email);
email.setToAddresses(toAddresses);
List<String> ccAddresses = new List<String>();
ccAddresses.add('magulancse24@gmail.com');
email.setCcAddresses(ccAddresses);
email.setSubject('Happy Birthday. Have a blast -- Birthday Reminder!');
String message = '<html><table cellspacing = "7"><tr><td style="font-weight:bold;color:green;">Happy Birthday!!!</td></tr><tr><td style="font-weight:bold;color:pink;">Many more Happy returns of the day.</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td style="font-weight:bold;">Cheers,</td></tr><tr><td style="font-weight:bold;">Magulan D</td></tr></table></html>';
email.setHtmlBody(message);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
}
}
}
global void finish(Database.batchableContext info)
{
}
}
1)If DOB is Feb 29 Leap year.How to find next birthday for that particular date?
No Need Validation rule for this code.
End-of-century years 1700, 1800,1900,2100 these years are not leap year in these problems are resolved.........
To find the next Birthday formula
How to create......
step-1: create the custom field for Date of Birth----It's type-Date
step-2: create the formula field for Birthday ---It's type-Date
code:
iIF ( MONTH (ramki__DOB__c)=2 && DAY (ramki__DOB__c)=29,
DATE(
IF(Year(Today())<=Year(ramki__DOB__c),Year(ramki__DOB__c),
IF(
OR(MOD(Year(Today())+ 4-MOD(Year(Today()),4),400)=0,
AND(MOD(Year(Today())+ 4-MOD(Year(Today()),4),4)=0,
MOD(Year(Today())+ 4-MOD(Year(Today()),4),100)<>0)),
Year(Today())+ 4-MOD(Year(Today()),4),
Year(Today())+ 8-MOD(Year(Today()),4))
),
MONTH(ramki__DOB__c),DAY(ramki__DOB__c)),
IF (DATE (YEAR(TODAY()),MONTH(ramki__DOB__c),DAY(ramki__DOB__c)) > TODAY(),
DATE (YEAR(TODAY()),MONTH(ramki__DOB__c),DAY(ramki__DOB__c)),
DATE (YEAR(TODAY())+1,MONTH(ramki__DOB__c),DAY(ramki__DOB__c))
)
)
it's correctly worked for leap year dates.......
this is code for find the next Birthday friends......
Easily Calculate Age:
create formula field -------(Number)
Age=YEAR( ramki__BirthDay__c) - YEAR(ramki__DOB__c)
----
softramki@gmail.com
+919944112175