Closed medoingthings closed 3 months ago
Notifications cannot be queried, as they aren't elements. There are no plans to make them elements, as this adds needless overhead.
You can fetch the notifications via the form, which can be fetched from the submission.
$invitationSubmission->getForm()->getNotifications();
You can query SentNotification
elements, which might be more useful if you're trying to re-send failed notifications.
Yes, I’m after the SentNotification
– great news that I can already query them! But I’m stuck in how to do it. This doesn’t work:
// attempt #1
$invitationNotification = \verbb\formie\elements\SentNotification::find()
->relatedTo($invitationSubmission->id)
->all();
// attempt #2
$invitationNotification = \verbb\formie\elements\SentNotification::find()
->submissionId($invitationSubmission->id)
->all();
Any hint in the right direction would be much appreciated. Is there anything in the documentation about this? Couldn’t find it.
So you can't use relatedTo
as they're not hooked up to relations. I've just added submissionId
and notificationId
params to query by. To get this early, run composer require verbb/formie:"dev-craft-4 as 2.1.6"
.
Love the fast pace and reaction time. Thank you so much!
What are you trying to do?
I’ve built a system that allows users to manage inhouse trainings. At two points a Formie form is used to send out invitation and follow-up emails to participants.
Sometimes those notifications aren’t sent by the SMTP server and I can see that in the „Sent Notifications” area (red indicator next to notification), which is great. But I would like to be able to show the training editors whether the invitation/follow-up mails were sent successfully or not.
Right now I only query the submissions by doing this in my Craft module:
So I know the form was sent successfully, but that’s not enough, because the notification sending can go wrong and I want to act on it, if it did go wrong…
What's your proposed solution?
I would like to be able to query not only for submissions, but for notifications as well. E.g.:
What do you think? Have you already considered that at some point?
Additional context
No response