Batch edit Easy Form's mailer Body (signature)

Does anyone have some code or a smart way to add text to the mailer of Easyform

( I have more than 100 EasyForms, and I want to add one line as body signature (Please check, bla bla… )

Is an EasyForm object any different than other content types?

My first thought would be to do this in an upgrade step of your policy package.

Was going to provide a code sample, but unfortunately all I have is very customized. You basically have the portal catalog return the objects, iterate over the objects and modify the signature, then update the object, reindex etc...

The 'maling action' is not part of the content type itself, I think, it probably needs to be done a different way (if the 'mailing action' was a 'content type', it could probably be done with plone.api, but I have no clue if this is possible

Ok, I didn't realize this. Then maybe check what the template does... From the readme:

The mailer stores a HTML template for sending the results of the form. You can override it with a file named in your site. If it is not found the default from the default_schemata directory of this package is taken. If you plan to override start with the the file and make sure it is a valid pagetemplate.

From a cursory glance: I do think the mailer_action and its properties is saved on the object itself. See:


I can not figure out where the mailer fields actually are stored

(they are not in context.body_footer of the easy form, so this will not work:

all_items = context.portal_catalog(portal_type='EasyForm')

for item in all_items:
    #myitem = item.getObject()
    item.body_footer = RichTextValue('Mottatt:', 'text/html', 'text/x-html-safe')

add a breakpoint() and inspect the object, maybe the data is in the annotation.

I don't have 'access to Plone/computer with Plone' before Monday, but how to get/find (and write) data in annotations from pdb ?

the actions are stored here collective.easyform/ at master · collective/collective.easyform · GitHub in IEasyForm.actions_model. The data is stored with the MailerHandler collective.easyform/ at master · collective/collective.easyform · GitHub which is a plone.supermodel.exportimport.BaseHandler ... could not get further where to access the data, but that might be a pointer

I could not figure it out, so I updated all (150) items manually…

Here some code to get the actions and then the ISaveData. I think that you can use IMailer instead of ISaveData.

Here the implementer

but I agree it is quite obscure how to set things, maybe action.body_post?

So it would be:

        from collective.easyform.api import get_actions
        from collective.easyform.interfaces import ISaveData
        self.context = EasyFormForm(self.context, self.request)
        form = self.context.context
        for action_id in get_actions(form):
            action = get_actions(form)[action_id]
            if IMailer.providedBy(action):
                action.body_post += "\nPlease check, bla bla… "

(this for every easyform)

Off topic, and I do understand (some of) the logic behind things, but:

From a User point of view (or at least the users of this site), things are 'scattered around'.
To them, it is confusing that the 'Form Prologue' can be changed by clicking 'Edit', and then 'thanks page' is at a tab (while edit).

Then they have to change the form fields by clicking 'Define Form fields' (could we use another wording) 'a different place', and when they have finished editing the fields, click "Done" and (also) click "View" before they can Define/change 'Form actions".

(this is when they go to the thanks page and call me since they can not find the 'mailer stuff'. )

I am not sure how this could be 'better', but maybe some buttons on the edit schema or a tab with links. Maybe 'Define form fields actions could be styled like a tab at top (and renamed to just "Fields" (?).

UPDATE: (I mention this because this is the reason I had to edit all these)