Contents

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:๐Ÿช›

๐Ÿ‘‰Go to Setup > Notification Builder > Custom Notifications .
Create a new Custom Notification Type by giving name and supported channels(Desktop/Mobile)

Image 1

Image 2


๐Ÿ‘‰you can trigger notifications from APEX or Flows

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:

Image 4


Image 5


Image 6


Image 7


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: Image 8

๐Ÿ”— ๐Ÿ”—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