Display form data with a parameter in the to field of a Send Email Action

By: David Kelnick | Asked: 04/11/2022
ForumsCategory: General questionsDisplay form data with a parameter in the to field of a Send Email Action
David Kelnick asked 2 years ago

I'm setting up a form where a hospital requests an outsourced PICC line nurse for a patient. In the form the hospital/client selects their facility. Based on that facility an SMS text using Twilio is sent to a list of nurses numbers who service that facility.

It currently works like this:

1. I have a classic view of a form with the nurses info
2. I've created a comma-separated list of phone numbers for the nurses
3. There's a filter in the view, which is: Facilities Serviced like [get param=facility]
4. In the main form, in the Twilio action, in the "to" box I have [display-frm-data id=598 facility="[139]"]

This creates a comma-separated list of numbers for the nurses that service the facility chosen in the main form.

This works great, but I can't get it to work for Email.

In the Form Actions I select Send Email and in the To field I have [display-frm-data id=600 facility="[139]"]

The 600 view uses the same filter and it displays the nurses email instead of their phone numbers. This generates a comma-separated list of emails but the emails aren't being sent and I don't know what the issue is. It's not a SMTP issue, because I've tested it with putting in [admin_email] and that works.

Any ideas?

Is there anyway I can see what the shortcode output is of [display-frm-data id=600 facility="[139]"] so I could troubleshoot the issue more effectively?

1 Answers
Victor Font answered 2 years ago

If you know how to examine PHP var1ables, you can use the frm_email_header hook to see the email header.

David Kelnick replied 2 years ago

Hi Victor. If I were to purchase the WP Mail SMTP plugin and enable the logs, do you know if it would allow me to see the recipients of an email even if it failed delivering?

Victor Font replied 2 years ago

I don't know. I don't use the WP Mail SMTP. I have used this one and it will show you the recipient in the logs: https://wordpress.org/plugins/check-email/

David Kelnick replied 2 years ago

Thanks Victor. I've confirmed that when using the shortcode [display-frm-data id=600 facility="[139]"] in to "to" box for an email action it's not sending to anyone.

I'm wondering if this is a limitation of formidable forms for an email action? It just seems so odd because it works perfectly fine for sending out SMS.

Victor Font replied 2 years ago

When you say, "it's not sending to anyone", how did did you come to that conclusion? Was there an entry in log for your test emails?

If you used the same logging plugin that I do, then when you view the logs there is an entry. The log entry is a CPT that contains the content of the email. There's also a status. If the status is a green circle with a check mark, the email left the WordPress server. that makes it a delivery problem. Why is there a delivery problem? Was it with the way Formidable did or did not generate the expected outcome for the mailing list? Or, was it a different problem, an unknown error? If there was no entry in the log, or if there is an entry and the status shows anything other than green, then you're definitely dealing with an unknown error that could be programming and/or server related.

I have to admit, the way you use a view's output to generate the mailing list is a new one on me. This is the first time anyone has ever brought this up and I've read a lot of questions in Formidable's Community Forums over the years. You've found an unique and inventive approach to problem solving. It's interesting that you thought of it. Thank you!

It never would have occurred to me to try using a view's output. As a developer, my approach would be to write my own shortcode. My own shortcode would provide the flexibility to pass parameters that allow me to select mailing lists from different Formidable sources. One shortcode would work across many different email types.

Please, I'd really like to understand what led to your conclusion. If you share your knowledge, you might be able to help a lot of people that read these threads looking for a solution. Thank you, again.

David Kelnick replied 2 years ago

Hi Victor, I came to the conclusion that it's not sending to anyone because I installed the Check & Log Email plugin and when I use the shortcode in the "to" field for a Send Email Action it's not in the log.

Also, when I look at the entry itself in formidable and click 'Resend Emails' it says 'Resent to no one'

As far as how I came to this solution, I emailed Formidable support in January the following question:

I have a service request form where a healthcare provider can request a outsourced PICC line nurse for their patients. I have about 60 nurses that service 170 facilities spread across 10 states. When a service request form is filled out by a client I'd only like the SMS messages to go to the nurses that are in close proximity to the request. That could be handled by the State field or the Facility field in the form. Is there a way to do this?

The response from Laura at Formidable:

Do you have a form with an entry for each nurse, with their number, state, and facility?

If not, would it be possible to create this and keep it up to date when nurses leave and join?

If you have such a form, here's my idea (untested, though similar approaches have worked in the past):

1. Create a classic View of the form with nurses info
2. For the Content, create a comma-separated list of numbers, as described here:
https://formidableforms.com/knowledgebase/conditionals/#kb-comma-separated-list
3. Add a filter for the field you want use for this, state or facility. Use [get param] for the filter value. So, if you want to use state, you could have a filter like this:
state is equal to [get param=state]
4. in your main form, in the Twilio action, in the "to" box, put the View shortcode. Add the state or facility info as a param. So your View shortcode may look like this, where 100 is the id of the state field:
[display-frm-data id=5 state="[100]"]

This should give a comma-separated list of the numbers of the nurses in the same state.

Victor Font replied 2 years ago

I have a lot of respect for Laura, She's really knowledgeable. If she says this works, then it works. Her response is about Twilio, though, not Send Email. The two actions might not work the same way.

David Kelnick replied 2 years ago

Yup it definitely works for Twilio. I just assumed it would work for Send Email too, but that doesn't seem to be the case. I think I'll just use a bunch of conditionals in the "to" field for a Send Email to accomplish something similar.

Victor Font replied 2 years ago

If you use the https://formidableforms.com/knowledgebase/frm_email_header/ hook, you can avoid using conditionals and shortcodes.

David Kelnick replied 2 years ago

Unfortunately I'm not a developer and don't know what to put into that php to make it work.

Victor Font replied 2 years ago

Then, I suggest you consider hiring a developer. Writing that much code to provide an answer in a community forum is a little much to ask of any volunteer. All of us that regularly answer questions here are volunteers. We do this because we love helping people solve their problems. We have no affiliation with Strategy 11.

If you need help finding a developer, please visit our Developers Directory and search for a resource at https://formidable-masterminds.com/developers-directory/.

David Kelnick replied 2 years ago

Thanks Victor, I plan on getting some development help.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right