- notification.setTitle('');
- notification.setBody('');
- notification.setNotificationTypeId();
- notification.setTargetId();
- notification.send();
for (Campaign obj : listTarget) {
Messaging.CustomNotification notification = new Messaging.CustomNotification();
// Set the contents for the notification
notification.setTitle('');
notification.setBody(obj.Name);
// Set the notification type and target
notification.setNotificationTypeId(notificationType.Id);
notification.setTargetId(obj.Id);
// Actually send the notification
try {
notification.send(setUserId);
} catch (Exception e) {
System.debug('Problem sending notification: ' + e.getMessage());
}
}
CustomNotificationType은 Salesforce Org 내에서 만든 사용자 정의 알림을 말한다.
CustomNotificationType notificationType = [
SELECT Id, DeveloperName
FROM CustomNotificationType
WHERE DeveloperName = 'Custom_Alert'
];
notification.setNotificationTypeId(notificationType.Id);