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
JayeeJayee 

process notification

Hello

In this Summer 19 Release, new fuctionality was added new process notification through the ProcessBuilder. (https://help.salesforce.com/articleView?id=process_action_customnotification.htm&type=5)

So i want to give a notification when the other user press certain 'like' button, owner of the record should have to get the 'Ring' shape notification alarm.

 

So i would like to use it on the Apex Code. not the process builder. i thought that Processbuilder could make it, Apex has to be made on the code as well.
Does anyone have applied this notification functionality?

Thanks for reading.

Jay

Ajay K DubediAjay K Dubedi
Hi Jayee,

Once you’ve created the Custom Notification Type, you can trigger the notification in one of two ways: Process Builder or via the REST API.

Send notification via the REST API:
If you want to send a request via the REST API, the first step is to get the ID of the notification you want to send. The easiest way to do this is the query for it using the Tooling API. I used:

SELECT id,customNotifTypeName FROM CustomNotificationType

With my ID in hand, I can continue to form my REST API call with the Title and Body of the notification I want to send. My end Custom Notification looked like this:

curl --include --request POST \
--header "Authorization: Authorization: Bearer 00DR...xyz" \
--header "Content-Type: application/json" \
--data '{ "inputs" :
  [
  {
    "customNotifTypeId" : "0ML1k0000008OIFGA2",
    "recipientIds" : ["0051k000001G0f5AAC"],
    "title" : "Case Closed!",
    "body" : "Your High Priority Case has been Closed.",
    "targetId" : "5001k00000BrdQ9AAJ"
  }
  ]
}' \
"https://gs0.salesforce.com/services/data/v46.0/actions/standard/customNotificationAction"

You’ll notice my request was a bit different this time, just letting the user know when any cases they owned were closed, but you can start to see that with any idea, you can send a custom notification from almost anywhere!

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