Push Notifications on Salesforce๐

ย
Have you ever thought on how we can show Push Notifications on salesforce screen?๐ค๐ค๐ค
It is a great way to alert your salesforce users about anything which needs immediate attention. And It may not be as complex as you think!๐ช๐๐ฒ
ย
Lets break this up in to 2 steps:๐ช
Create a Custom Notification Type
๐Go to Setup > Notification Builder > Custom Notifications .
Create a new Custom Notification Type by giving name and supported channels(Desktop/Mobile)
Trigger the notification
๐you can trigger notifications from APEX or Flows
๐ขFrom Flow
You can use Action element->select Action ‘Send Custom Notification’ and pass in the needed details like :
- ๐๐ถ๐ด๐ต๐ฐ๐ฎ ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ ๐๐บ๐ฑ๐ฆ ๐๐ฅ - Record Id of Custom Notification Type
- ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ ๐๐ช๐ต๐ญ๐ฆ - Title for your notification
- ๐๐ถ๐ด๐ต๐ฐ๐ฎ ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ ๐๐ฆ๐ด๐ด๐ข๐จ๐ฆ - Message you want to show in Notification
- ๐๐ฆ๐ค๐ช๐ฑ๐ช๐ฆ๐ฏ๐ต ๐๐๐ด - A variable of type text with multiple values allowed
- ๐๐ข๐ณ๐จ๐ฆ๐ต ๐๐ - The record you need to open on clicking the push notification
etc
Here are few screenshots to understand this better:
๐ขFrom Apex
You can use CustomNotification class to create a push notification as below.
๐๐ฆ๐ด๐ด๐ข๐จ๐ช๐ฏ๐จ.๐๐ถ๐ด๐ต๐ฐ๐ฎ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ ๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ = ๐ฏ๐ฆ๐ธ ๐๐ฆ๐ด๐ด๐ข๐จ๐ช๐ฏ๐จ.๐๐ถ๐ด๐ต๐ฐ๐ฎ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ();
๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ.๐ด๐ฆ๐ต๐๐ช๐ต๐ญ๐ฆ('๐๐ฑ๐ฆ๐น ๐๐ถ๐ด๐ต๐ฐ๐ฎ ๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ');
๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ.๐ด๐ฆ๐ต๐๐ฐ๐ฅ๐บ('๐๐ฉ๐ฆ ๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ๐ด ๐ข๐ณ๐ฆ ๐ค๐ฐ๐ฎ๐ช๐ฏ๐จ ๐ง๐ณ๐ฐ๐ฎ ๐๐๐๐๐๐ ๐ต๐ฉ๐ฆ ๐๐ฑ๐ฆ๐น!');
๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ.๐ด๐ฆ๐ต๐๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ๐๐บ๐ฑ๐ฆ๐๐ฅ(๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ๐๐บ๐ฑ๐ฆ.๐๐ฅ);
๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ.๐ด๐ฆ๐ต๐๐ข๐ณ๐จ๐ฆ๐ต๐๐ฅ(๐ต๐ข๐ณ๐จ๐ฆ๐ต๐๐ฅ);
๐ฏ๐ฐ๐ต๐ช๐ง๐ช๐ค๐ข๐ต๐ช๐ฐ๐ฏ.๐ด๐ฆ๐ฏ๐ฅ(๐ณ๐ฆ๐ค๐ช๐ฑ๐ช๐ฆ๐ฏ๐ต๐ด๐๐ฅ๐ด);
please note this is rough code for understanding ,see the below Screenshot for exact code:
๐ ๐Here is the link to SF documentation on CustomNotification Class
๐ Here is a nice article on the same from SF Ben
This Content was originally posted in linkedin View Post