Your software
My Mautic version is: 2.16.2
My PHP version is: 7.2
Your problem
My problem is:
I have a situation that one contact can have multiple companies. And creation is working as expected, both from dashboard and API.
Now, I have a campaign to notify the user on the status of their companies (Company A trial expired, Company B payment success etc.).
I created segments that contains the contacts based on company fields and then I have campaigns that are run for various segments.
All that works just fine until the email is sent. Mautic always take the information from primary company which results in sending misleading information to the contacts.
So for example: Company A is primary company for a contact.
Company A have trial expired, the campaign is run and the contact received proper email with Subject Company A trial expired
Howerver, in case of company B having their payment failed the campaign should send email with subject Company B have failed payment. But instead, the contact received subject Company A have failed payment
I guess this is a bug, or there is some work around it which I canāt figure out.
Did anybody else came across similar issue?
To start with I suggest you upgrade Mautic to the latest version
Can you explain your business use case? Why do you have a contact that is attached to two companies?
Letās say you have many agencies (stored as contact) who serves multiple partners (store as company).
One agency can have many companies. Companies have different custom fields, for example
logo color
logo size
logo material
You as the provider through agencies you can notify all your agencies who have partners (saved as company) in case there is a discount in yellow, metal logo materials.
@joeyk maybe you can help me with this one? Or someone elseā¦I find it an very interesting case
We are trying to set up Mautic as an resevervation tool. We connect reservation software with an API to retrieve reservations and send them to Mautic. In Mautic we use companies as reservations. So the reservation ID is the company name. The issue I ran into is that when a contact has multiple reservations (companies) and I want so send an e-mail with company custom fields tokens, Mautic will always pick the information from the primary company.
So for example: I have an arrival date as a custom company field. 2 weeks before the arrival date the contact should get an email with the reservation ID and information about the accommodation. But if a contact has multiple reservations it will always get an email with the reservation ID form the primary company, which is not always the right ID.
If the reservation in 12 days is made later than that will be the primary company. When I send a mail for the reservation in 10 days that mail will be filled with information from the reservation that is made for 12 days.
I thought about switching primary company with a campaign action, but I couldnāt come up with a solution on how to change the primary company to the right one?
For example: I have one reservation (001) made on 1-1-2024 with an arrival date of 1-3-2024. And I have another reservation made on 1-2-2024 (002) with an arrival date of 1-4-2024. So the reservation for 1-4-2024 (002) is the primary company.
If I want so send mails, 2 weeks before the arrival date. Then on 15-2-2024 a mail will be send for reservation 001, but because the primary company is 002 all the information in the mail will be about 002 instead of 001.
You can place all the reservations in a form. The form entries are connected to a person, and you can have a one to many relationship, just like with companies, but you donāt have to hack the system. At least not the same way.
Mautic Twig Templates Plugin is able to parse, manage, compute form entries. Here is the plugin.
Iām not sure if parsing form results is fully documented, but Iām happy to hop on a call and guide you through it.
Iām also building an event platform with Mautic for a client, and this plugin helped me a lot.
Yes, I tried to set that up yesterday, but you canāt use the formfield token in a campaign mail. Only as an form action. So I stopped there.
But I havenāt thought about the Twig Templates Plugin. I now see they have a {{ formresults }} option. Thatās looks like a great option. Iāll try this next week.
Iām also interested in the event platform :). Maybe good content for your blog?
I installed the Mautic Twig Templates Plugin. The {{ formresults }} option gave me the same problem. As soon as there a multiple form submissions the plugin uses the information from the last submission. And that is not always the right information.
I didnāt really find helpfull information about parsing form result, so if you can help me further? That would be greatā¦
Thanks for sharing. The issue I ran into is that I get the wrong info in my emails. I explained here in this topic before.
The problem is that if someone submits multiple forms, the mail I send will always contain the data from the last form submission. And sometimes Iāll need the information from an older submission. Is there a way to force Mautic to send the formresult from a previous submission?
It works great. I didnāt try the formresults yet. I also got it working with the following snippet:
{% for company in contact.companies %}
{% if company.arrivaldate == ānowā|date_modify(ā+14 dayā)|date(āY-m-dā) %}
I set up a segment to check if the arrival date is 14 days in the future and then it will start a campaign to send the email with the right info. After the mail is sent the contact is removed from the segment.
@joeyk: Iām wondering how this works? I was expecting that after the contact is removed from the segment it would be added again a couple of minutes later when the segment/cron jobs checks if contacts match the filter settings? But that didnāt happen. Is that normal behaviour?