Send personalize email via workflow

Hello,
I am looking for a solution to the following situation…
A table called “Companies” contains data about companies (ičo, name, address, status, etc.). The second table called “Persons” contains data about contact persons (name, surname, job title, phone number, email, etc.). There is a classic 1:N relationship between the tables.

I created a workflow that contains a trigger “When record changes” in the Companies table and a condition that ensures that the workflow continues only when the Status field has one specific value. The idea is to send an email to all contact persons of the given company when the Status changes to a specific value. Therefore, the Send Email action follows. The recipient type is Table item, specifically “Persons (eml)”. The body of the email contains variables from the Companies table.
This solution works, one email is created and that contains as many recipients as the company has contact persons. Unfortunately, it is not possible to personalize the sent email for each recipient using data from the Persons table (name, surname, etc.).

Another idea was to insert a foreach loop into the workflow instead of the Send Email action, loop through the records in the Persons table and insert the sending of the email into this loop. But the foreach loop will loop through all the records in the Persons table, not just those that are linked to the Companies record from the trigger. The loop allows use a filter to limit the flow to only some records, but the filter condition works with fixed values. I haven’t found a way to write a condition for a dynamic link (relationship) to the Companies table into the filter.
Is there any solution for this scenario?

Thanks…
Kuba

Hi Kuba,

thanks for the detailed description — that helps a lot. You’re right that the current workflow engine doesn’t support dynamic filtering inside the foreach block based on related records.

The recommended solution is to use a helper table (e.g. Communication):

  1. In the Companies workflow, use JavaScript to query related Persons and create one Communication record for each of them, including both person and company data.
  2. In the Communication table, use a second workflow (onCreate) to send a personalized email using the fields from that row.

This way, each recipient receives their own message, personalized with their name, job title, and company info, and you keep full control over the process.