You are viewing limited content. For full access, please sign in.

Question

Question

Sending multiple emails/querying database not working.

asked on June 18, 2018 Show version history

So I have a process in which a user submits a form. The user can choose multiple departments via a table in the form. There are multiple HR employees, every department has a HR employee over it. I am querying the database to obtain the email address of the HR employee. So let's say I chose 1600 CIVIL RIGHTS and 2700 TRANSIT COMMUNICATIONS CENTER as my two departments. 

I want to be able to send it to both HR employees that are over those departments. But every HR employee has multiple departments, so if I chose two different departments that both happened to have the same HR employee over them, I don't want them to get two of the same email. I got it to work for the most part, the only issue I have is that when I send the email, it only gets sent to the last department's HR employee. So I believe my issue is with the table and pulling multiple values from it.

Anyone have any ideas?

 

0 0

Answer

SELECTED ANSWER
replied on June 18, 2018

Hi Rex,

It's a bit hard to tell, but I think your workflow is sending email only to the last because within the For Each loop, you create a token, then overwrite it on the next iteration. The only email address to "survive" this then is used by the Email Activity.

My idea would be to create some blank multivalue tokens before the For Each, and append the email addresses you find in the for each row. Then you can go through, compare all the values in the token to make sure they are unique, and then send emails to each address of the cleaned-up multivalue token.

0 0
replied on June 18, 2018

So I would have to create a blank token for each email then?

0 0
replied on June 18, 2018

Not a blank token, since you do not know how many departments may be added. It is probably best to put the emails from one request into one multi-value token.

0 0
replied on June 18, 2018

So I create a blank multivalue token first (called HRBP email). 

 

Then, for each row (Dept selected), I assign values to HRBP email token?

0 0
replied on June 18, 2018 Show version history

Yes. Use the Assign Token Value activity inside the For Each, select that newly created HRBP email token, and keep the Append to existing values option selected. Then you will create an array of email addresses. 

Depending on the email client, it might be picky about wanting a semicolon (e.g. email; email; email) rather than separating by commas. Also, if you want the emails to go out individually instead of employees seeing each other's addresses jointly, you'll have to use an additional For Each Value to send separate emails to addresses rather than one email with multiple addresses.

0 0
replied on June 18, 2018

Does this look correct to you?

0 0
replied on June 18, 2018 Show version history

Almost correct. You probably want to do the Remove Duplicates after the entire For Each row loop. 
Does each row of your database only contain one email address? If so, then the above should be fine.

0 0
replied on June 18, 2018

I changed my token to what you suggested. So then when configuring the email, I would apply the remove duplicates function?

0 0
replied on June 18, 2018

Yes. Also, to make sure all the addresses are included, make sure to apply indexing.

A few of my suggestions have made some assumptions about your Workflow and data source. Feel free to update me on how the testing goes!

0 0
replied on June 19, 2018

Just completed testing with no errors, thank you Karina!

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.