Quantcast
Channel: Planet Plone - Where Developers And Integrators Write
Viewing all articles
Browse latest Browse all 3535

UW Oshkosh How-To's: How to create a conditional mailer adapter

$
0
0

I'd love to take credit for this but really this was pointed out to me by Kim Nguyen. I'm just documenting it so I don't forget how to do it later :). Oh and a shout out to Steve McMahon who created PFG to begin with (dude is awesome) :).

conditionalMailerAdapterCheckboxesImagine wanting a form that would have a set of checkboxes with email address, departments or people next to those checkboxes. Your guests would fill out the form and choose which of those email addresses or names that they want the form to go to. The form would be sent to the owner of the form and CC'd to whom ever the guest chose via those checkboxes.

This solution requires one "Mailer Adapter" for every email checkbox field

This was tested with: Plone 4.2.3

SETUP

  • Create the ploneformgen form
  • Choose the "quick edit" tab and choose the "edit (pencil)" icon
  • Set the main "Mailer Adapter" to whom ever should get this email. You can also set the CC option under "addressing" if needed

CREATE THE EMAIL FIELDS

  • Create a "checkbox field"
  • Name that field something easy to remember like "cc-joe-smith". This field will be the first conditional email address

MailerAdapterActionsCREATE A NEW MAILER ADAPTER

  • While in "quickedit" add a new "Mailer Adapter" under "Actions"
  • Name it something clear like "Mailer-to-Joes-Department"
  • In the "Recipient's e-mail address" dialouge add the person email address. You can also set the CC option under "addressing" if needed
  • Choose the drop down and choose "overrides"
  • Under "Execution Condition" copy and paste the following expression. Note that "cc-joe-smith" is the same ID as you used for the email field.

  • python: request.form['cc-joe-smith'] 

FINISHING UP

Thats just about all you need. Repeat this process for every additional email address you want to add. Make sure that the mailer adapter(s) are checked on under the "Quickedit" tab.


Viewing all articles
Browse latest Browse all 3535

Trending Articles