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
AK_SmithAK_Smith 

Post to chatter the list of users who have birthdays this week

Hi! 
Is there any way to automatically post to chatter message on the weekly basis with the list of users who have birthdays this week (name and date)? 
NagendraNagendra (Salesforce Developers) 
Hi Smith,

You should just write a schedulable batch job that runs once every day. (Unfortunately, the workflow doesn't support chatter posts (yet)).

Where your batch job's query basically is, get all the users which birthday equals today, and make a Chatter Post to their feed. Also, refer to the sample code below:
Global class HappyBirthday implements Schedulable{

global void execute(SchedulableContext sc) {

 List<user> lst=[Select id,name from user where date_of_birth__c =today];
   for(User u:lst){
FeedItem post = new FeedItem();

post.ParentId = u.id;

 post.Body = 'Happy birthday '+u.name;

   insert post;
}

} }
Hope this helps.

Kindly mark this as solved if the reply was helpful so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks,
Nagendra
AK_SmithAK_Smith
Hi! Thanks! What if there more than 1 user with a birthday today?