+ Start a Discussion
Jeremy SparrellJeremy Sparrell 

Push notifications on created cases

I cannot get push notifications to fire in the console when a new Case is created.  It works for updated cases and create on other objects.
Suraj Tripathi 47Suraj Tripathi 47

Hi Jeremy Sparrell,

Please see the below steps to set up push notifications in salesforce on a particular action. There are two ways which I suggest you:-

Step 1:- Please go to the setup and type Custom Notification Type and select it. Please create a new custom notification record if not created.

User-added image

Create a process builder which will fire on a specific object record creation which you will select in a process builder object option and see the below images for reference:-

User-added image

User-added image

Step 2:- After creating a custom notification record you can also write a trigger on that particular object instead of process builder:-

*** Trigger ***

trigger PushNotificationTriggerOnCaseCreation on Case (after insert) {


******** Apex Code *********

public class PushNotification {
    public static void sendPushNotification(){
            List<Case> caseRecord=new List<Case>();
            caseRecord = [select Id from Case where Id=:Trigger.New limit 1];

            system.debug('-------In sendCustomnotification Method------');
            Messaging.CustomNotification notificationObj = new Messaging.CustomNotification();
            notificationObj.setBody('New Case is created with id: '+ caseRecord[0].Id);
            notificationObj.setTitle('Case Creation');
            CustomNotificationType type = [SELECT Id FROM CustomNotificationType WHERE DeveloperName = 'Custom_Notifatication'];
            notificationObj.send(new Set<String> { Userinfo.getUserId() });
        catch(Exception ex)
            System.debug('Exception at line >>>> '+ex.getLineNumber()+'Exception >>>>>> '+ex.getMessage());


The output will be like:-

User-added image


I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.

Thanks and Regards,
Suraj Tripathi