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
Mike JackMike Jack 

Custom Push Notification

Hi All,

Can we create custom push notification in Salesforce using Apex Class or Trigger?
The use case is to popup the notification to a particular user when a Lead is assigned to that user. 
Can anyone share the sample reference code. Thanks in advance.
Raj VakatiRaj Vakati
Can we create custom push notification in Salesforce using Apex Class or Trigger?

You no need to use apex class or trigger to do this every time .. You can use execute anynamus window to create push topic once 
 
PushTopic pushTopic = new PushTopic();
pushTopic.Name = 'InvoiceStatementUpdates';
pushTopic.Query = 'SELECT Id, Name, Status__c, Description__c FROM Invoice_Statement__c';
pushTopic.ApiVersion = 44.0;
pushTopic.NotifyForOperationCreate = true;
pushTopic.NotifyForOperationUpdate = true;
pushTopic.NotifyForOperationUndelete = true;
pushTopic.NotifyForOperationDelete = true;
pushTopic.NotifyForFields = 'Referenced';
insert pushTopic;

 


The use case is to popup the notification to a particular user when a Lead is assigned to that user. 

Yes .. You need use the above push topic and show the popup 





https://developer.salesforce.com/docs/atlas.en-us.api_streaming.meta/api_streaming/create_a_pushtopic.htm

https://www.jitendrazaa.com/blog/others/tips/streaming-api-using-jquery-salesforce/