Custom Notification Demos
Sample Process Builder, Flow and Apex code illustrating how to utilizae Custom Notifications in Lightning Experience and Salesforce Mobile. See blog for more details.
- Deploy to DX scratch org via
- Run the query
sfdx force:data:soql:query -q "select id, developername from CustomNotificationType" --usetoolingapi
- Update the file
CustomNotificationTypeIdMap.BatchApexError.md-meta.xmlwith the Id returned by the query.
NOTE: The need to define a Name to Id map for Notification Types is only required when sending Custom Notifications from Flow at time of writing. Process Builder does not require this. If you want to get the Id of the Notification Type in a regular org run
select id, developername from CustomNotificationType from the Developer Console and ensure you to tick the "Use Tooling API" checkbox.
- Open the scratch org with
sfdx force:apex:execute(without parameters)
- Paste the following sample code in and press the indicated keyboard shortcut to run the code.
new CustomNotification() .type('BatchApexError') .title('Batch Error') .body('Some useful information') .sendToCurrentUser();
Or to test the Batch Apex Error Event handler....
Finally if you want to see notifications on your mobile, you will need to generate a user password via
sfdx force:user:password:generate to login to the scratch org (be sure to select sandbox login from the mobile).