Sample queries for querying notification histories through Data Query
Provides common use cases and sample queries for querying notification histories through Data Query.
Query for email failures
SELECT notificationId, CreatedOn, AccountId, ContactId, ObjectId, Subject, ErrorMessage
FROM notificationhistoryemail
WHERE status = 'Failed'
ORDER BY CreatedOn
DESC LIMIT 100
Query for email failures with advanced configuration
SELECT Account.AccountNumber, Account.Name, Contact.FirstName, Contact.LastName, notificationhistoryemail.Id, notificationhistoryemail.CreatedOn, notificationhistoryemail.Subject
FROM notificationhistoryemail
JOIN account on account.id = notificationhistoryemail.AccountId
JOIN contact on contact.id = notificationhistoryemail.ContactId
WHERE notificationhistoryemail.status = 'Failed' AND CreatedOn >= DATE('2023-10-08')
LIMIT 100
Query for callout failures
SELECT Account.AccountNumber, Account.Name, notificationhistorycallout.Id, notificationhistorycallout.CreateTime, notificationhistorycallout.ResponseCode, notificationhistorycallout.ResponseContent
FROM notificationhistorycallout
JOIN account on account.id = notificationhistorycallout.AccountId
WHERE notificationhistorycallout.ResponseCode <> 200
LIMIT 100
Query for callout successes
SELECT Account.AccountNumber, Account.Name, notificationhistorycallout.Id, notificationhistorycallout.CreateTime, notificationhistorycallout.ResponseCode, notificationhistorycallout.ResponseContent
FROM notificationhistorycallout
JOIN account on account.id = notificationhistorycallout.AccountId
WHERE notificationhistorycallout.ResponseCode = 200
LIMIT 100
Query for email notification history events
SELECT NotificationId, EmailHistoryId, AccountId, EventType, EventDetails, EventCount, CreatedDate, UpdatedDate
FROM notificationhistoryemailevent
ORDER BY CreatedDate DESC