(SOLVED) Display list of objects inside an email template ( Email Connector )

0
Hello everyone, I’m wondering if anyone have an idea of how I can display a list of objects into an email template? I’m using Studio Pro 8.18.22 I am retrieving a list from an external database via the Database Connector module, however I am only able to insert one object to replace the tokens in the email template, therefore I’m using the list operation for example Find, Head or Tail and this will only give me one specific object from that list.   I’ve been searching for solutions in the community forum but from what I’ve seen, it seems that the ReplaceToken java action gets mentioned but I cannot figure out how to use it because I can only access the member ValueObject, the TokenObject and TextToReplace members are blank and I’m not using the ReplaceToken action inside my microflow where I send the emails. There has to be a way to insert a list of objects into the email template.   The Email Connector documentation says:  “Data Object – entity object from which you want to extract the placeholder tokens (if you want to retrieve from multiple objects, then create a Non-Persistable Entity”   I am using a non-persistable entity and if I need to use a loop action, how do I use it to insert the list of objects into the email template? I inserted a picture of the microflow below.  Any input would be highly appreciated. Thank you :) 
asked
2 answers
3

Hi David, 

 

Typically the Email Connector is not really designed for working with lists in the email. 

 

“If you want to retrieve from multiple objects, then create a Non-Persistable Entitywhat is meant here is that if you want to combine data from e.g. the Account object and an Employee object, you should create an NPE and set the attributes yourself. Then that NPE is used for the CreateEmailFromTemplate action.

 

So what can you do if you want a list of N employee names in your email:

  1. If you know what the maximum number for N is you could create an NPE with as many attributes (Employee01, Employee02, … EmployeeN) as you need, and then make the tokens for it in your template config.
  2. If you don't know or don't want this: You can create an unlimited string attribute in the NPE and in your microflow fill it with the data and the markup for tabs and new lines…And then make a token in your template for that one. So you would have one string attributed filled with “John Doe, Jane Doe, Ted Something, Peter Pan” and the markup to split it in the mail.
  3.  Maybe a simpler solution is to create a DocumentTemplate as an attachment for the email, so that there is a list in the attachment but not in the email… https://docs.mendix.com/refguide/document-templates/

Go Make it

 

Jacob

answered
1

@David

Would this help you with your requirement: Mendix Forum - Question Details

answered