I could not find any post relating to this any help will be appreciated.

Is there anyway to bulk send custom notifications from apex without using a process builder or API?

If I use the following code, each time I send a notification a DML operation is consumed.

Messaging.CustomNotification notification = new Messaging.CustomNotification();
notification.setTitle('Update on issue ');
notification.setBody('There has been a new email communication for the issue!');

notification.setNotificationTypeId([SELECT Id FROM CustomNotificationType LIMIT 1].Id);
notification.setTargetId(Userinfo.getUserId()); // target object id

notification.send(new set<String>{Userinfo.getUserId()});

I will be having a batch process that will be dynamically generating the notification title and body and I was not able to find any method on Messaging class like the one we all know for bulk sending emails (Messaging.sendEmail(emails, allOrNothing))

[UPDATE] As this functionality is not developed I have created the following idea: https://trailblazer.salesforce.com/ideaView?id=0874V0000010y6zQAA

2 Answers 2


The notification system is designed to notify a bunch of people regarding a single update, not notify a bunch of people regarding many individual updates. You'll need to either reduce your batch size or use a Queueable, or restructure your logic such that you're not sending out excessive notifications.

  • Hi, thanks for the reply. The reason why I am not doing this with a PB is that the recipients are calculated using code because all the case team members need to be notified. I will see if I can find a workaround to send notifications using the standard process builder action and if not I will either need to move the logic to task or email. Nov 4, 2020 at 15:33
  • @RamiroIchazo You can notify everyone on the team at once, that's what setRecipientIds is for. You just can't send different notifications in bulk.
    – sfdcfox
    Nov 4, 2020 at 15:42
  • you are right, the question I have is that theoretically process builders support bulk functionality so if I use the PB to send the notification out I would then not be consuming that many DMLs as if I did using code(this is just a theory). If that is the case, I would just need to find a way of getting all the team members Ids so that I can set them as the recipients. Anyway, the question I initially asked was answered by you thanks for that and there is no way of bulk sending a list of notifications using apex Nov 4, 2020 at 15:53

I became concerned about limits when I saw this post, as I'm developing using the same apex methods. However when I debug the transaction I do not find that CustomNotification.send() counts toward DML statements or DML rows. I went as far as to call this statement over 200 times in case somehow the DML wasn't being reported properly but everything worked without a hitch.

Not sure what the behavior was a few years ago when this was posted, but it seems now that Salesforce does not count these sends toward any governor limits.

  • 1
    If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review Dec 31, 2022 at 3:40
  • It's not a new question - I believe this is the correct answer to this post's original question. I'll edit to make that more clear. Jan 1, 2023 at 6:06
  • 1
    it seems like it's a bug in the limits check. If you try to make a callout after running CustomNotification.send() you will get an error...
    – NSjonas
    Apr 10, 2023 at 23:15
  • 1
    That must be some idiosyncrasy specific to callouts, but again I was able to succesfully execute CustomNotification.send() over 200 separate times in a single transaction so clearly the DML statements limit wasn't being applied. Apr 15, 2023 at 0:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .