Report Email Inserts all Names instead of Just the Name of Recipient

To set up the question:

My report is intended to send an email (weekly on Monday) to:

  1. Contacts who have “Quote Reminder” selected in the list of options (enum list) in the column [Communications]
  2. Send a copy of the same email to anyone who uses the app with the [Select Role] of 'Admin" selected (enum) in the [Select Role] Column.

Here are the expressions I am using at this time.

TO: SELECT(Users[Email],CONTAINS([Select Role],“Admin”),TRUE)
BCC: SELECT(Contact[Email],CONTAINS([Communications],“Quote Reminder”),TRUE)

Hi <<Contact[Name]>>,
Email Body Here.

Question:
I received an email as an Admin that inserted (it appears) every name in the database after “Hi,” regardless of if “Quote Reminder” is actually selected.

Is the expression correct to restrict to just those with the “Quote Reminder” option selected and how can I keep it from inserting every person’s name in favor of just the recipient’s name?

I’m not super sure, but I believe <<Contact[Name]>> is telling AppSheet to pull the list of all Contact names. I think you just want to put <<[Name]>>. I believe the SELECTs are ok.

1 Like

Dave is exactly right. <<Contact[Name]>> will return every Name in the Contact table.

I am not sure whether your report is using the “For entire table” or the “For each row in table” option.

If you are using the “For entire table” option, the report will create a single email. With that option, there is no “current record” so you cannot specify Hi <<[Name]>> because the system does not know which record to pull the “Name” field from. You would need to write an expression that yields a list of names.

If you are using the “For each row in table” option, the report will create a separate email for each row in the table. With that option, there is a “current record” so you can refer to fields in that record. So you could specify Hi <<[Name]>> assuming that “Name” is a valid field in the current record.

1 Like

@Phil @Bahbus Thank you very much! The report was set for “entire table” so based on your observations of my errors this pretty much explains the results.

I have reset the report for “each row” and am sending it To: SELECT(Contact[Email],CONTAINS([Communications],“Quote Reminder”),TRUE)

Based on your input I would expect AppSheet to generate a separate single email for each record in the CONTACT table whose [Communication] column CONTAINS the value “Quote Reminder” and to not generate the email if that is not TRUE.

Do I have that right?

Thank you again!

Theoretically! It looks good as far as I can tell.

Based on your response, it sounds like you will specify “For each row”. Use your Condition to filter the rows from the “For each row” table. Your Condition should only include those rows that you want to generate a Report for. If you do that, the Report will be called once for each row in the table that matches the Condition. Each time the Report is called, its “current row” will be one of the matching rows from the table. Since you have a “current record” you can simply refer to the fields from that record in the “To”, “BCC”, and so on properties. You can also simply refer to the fields from that record in your workflow Body or Attachment template.

1 Like

@Phil Got it. So I’m specifying “for each row” and the “If this is true” condition is set to (CONTAINS([Communications],“Quote Reminder”)) and the “to” is set to [email].

That seems to make sense. Wanted to finish the thread with the solution for those searching the future.

Thank you!

Exactly.

The “For each row in table” design pattern is this:

  1. Pick a table that contains the row values you want to iterate over.
  2. Write a Condition that includes only the rows from that table that you want to perform the report action on.
  3. Write the report action based on it being invoked once for each matching row.
  4. In the report action you can use the field values from the current matching row by simply using the appropriate field name.
2 Likes