简体   繁体   中英

Send Mautic Form to different Recipients based on Formfield

I've a Mautic form with Radiobuttons where the User can select which Department he want to connect with.

o General Question (1)
o Sales (2)
o Technical Support (3)

I want to send the Request to the Person in Charge. So for example:

1: info@company.org
2: sales@company.org
3: support@company.org

I've tried different approaches, but non worked. The most dirty one was to set the values of the radio buttons as E-Mails and send the Form to the Contact. Worked in some way, but then off course saves the Radiobutton Input to the Database as customer E-Mail. So, only smart in the first place. ;) I've also tried campaigns, but couldn't find a nice way to use Formfields in the Campaign Templates.

I cannot accept that this couldn't be possible in a easy way. This Form gonna replace a Powermail Form in TYPO3 and there it kind of works like a charm.

Any hint is very much appreciated.

Sorry that you found the documentation bad - we are actually in the process of improving and migrating our developer docs, so please take a look at the WIP docs here: https://mautic-developer.readthedocs.io/en/latest/plugins/getting_started.html which are much improved!

(will also post this on the forum thread!)

After weeks and weeks of research and workarounds I got at the Mautic Form, here is my solution to this Challenge.

I really love Mautic and its extensiveness. It's just a great and powerful tool. But at this point it totally misses the market. For me it just feels so wrong and like a big error by design, when you have to create fake fields to handle formfields for such a simple task. Not talking about the problem when the user overwrite his records before the data being send.

As mentioned this is so easy to do in TYPO3 with Powermail and so I was thinking about creating a plugin, but the documentation on this is really bad.

So here is my solution, as I was looking for simple solution for me as well as the customer. Solution is tested and worked like a charm for me. Here's what you can do, for everyone also looking something like this:

  1. Create 1 custom field and label it “Owner (form)” - set Type to Text

  2. Create 2 MySQL Trigger as follows (just copy the code 1:1, should work out of the box):

    DELIMITER ;; CREATE TRIGGER set_lead_owner_from_radiobutton_on_insert BEFORE INSERT ON leads FOR EACH ROW IF (NEW.owner_form != NULL) THEN IF (SELECT count(id) FROM users WHERE users.id=NEW.owner_form) > 0 THEN SET NEW.owner_id = NEW.owner_form; ELSE SET NEW.owner_id = NULL; END IF; END IF;; DELIMITER ;

    DELIMITER ;; CREATE TRIGGER set_lead_owner_from_radiobutton_on_update BEFORE UPDATE ON leads FOR EACH ROW IF (NEW.owner_form != NULL) THEN IF (SELECT count(id) FROM users WHERE users.id=NEW.owner_form) > 0 THEN SET NEW.owner_id = NEW.owner_form; ELSE SET NEW.owner_id = NULL; END IF; END IF;; DELIMITER ;

  3. Create a form with a Radiobutton or Selectbox and set the “Contact Field” to our custom field “Owner (Form)” Note : Values of the Radiobuttons / Selectboxes need to be set to the User IDs of your Mautic Instance. So you have to create an user for every Select- oder Radiobutton-Option.

  4. Select for example “Send form results” in Actions and set “Send to owner” to yes.

That's it.

So what does it do. It's basically all about the MySQL Triggers. Every time a new Lead is created or updated and our custom field “Owner (form)” is not null and has a valid entry (User ID), the trigger copies the value from our field to the original Owner Field of the lead. So we can then use Owner of the Lead (in my case a Department) to send him a E-Mail.

I hope this is helpfull to someone. But even more I hope that Mautic is gonna fix this in the future, as I believe this a very essential task when it come to enterprise Websites.

Cheers, Lufi

Mautic Forum Discussion: https://forum.mautic.org/t/send-mautic-form-to-different-recipients-based-on-formfield/24363/13

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM