Wanting field value to be used as Recipient emails in Email Notification.

Dion Gee asked on May 26, 2020 15:05

I have a form which depending on a selection made by the user (selecting an office department) needs to control where the form "Email notification" is sent to. Seems simple enough especially when referencing articles like this one. However no luck.

I anticipated putting {%department%} directly in the Recipient emails field would in turn have the email sent to the correct department. I've tried every solution I can get my hands on and tested it thoroughly and unless I have a plain text email address in that field nothing is received. I could rattle off the other solutions inluding long winded macros but they all have come up empty.

Also note: Setting the "Confirmation email source field" in the Autoresponder tab to the above field does indeed work, so I know the data being provded by the field is correct. Hopefully someone can help with some insight!

Recent Answers


Juraj Ondrus answered on May 27, 2020 08:54

What is the "department" field definition? Is it a drop down or what? What are the values set for the selection? I would try using macro debug to see how the macro is resolved - it may give oyu hints what is going on.

0 votesVote for this answer Mark as a Correct answer

Dion Gee answered on May 28, 2020 01:37 (last edited on May 28, 2020 04:31)

"Department" is a drop down where the value is an email address and the text is the department name. When placholding $$value:Department$$ in the email or even putting {%department%} in the Subject box it indeed produces the email address we want.

Thanks for the debug suggestion, it has produced the following which I'm researching but theres not much out there in relation:

Error while evaluating expression: Department
CMS.MacroEngine.LexicalAnalysisException: Lexical analysis of the expression failed. Error near: ->>Department
at CMS.MacroEngine.MacroElement.ParseNext(String expression, Int32& index, Boolean supressError, Boolean isParamValue)
at CMS.MacroEngine.MacroElement.ParseExpression(String expression, Boolean supressError)
at CMS.MacroEngine.MacroExpression.ParseExpression(String expression, Boolean supressError)
at CMS.MacroEngine.MacroResolver.ResolveMacroExpression(ResolveExpressionSettings settings)

Screenshot of macro debug

Just seems very odd that this field works when using it as the selected field for "Confirmation email source field" and also works fine as {%Department%} in the "Subject" field, but the one place I need it it's throwing the above error.

I'll keep investigating.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 28, 2020 06:32 (last edited on May 28, 2020 06:34)

Could you please send some screen sots of your setup? IT works perfectly fine for me. Here is my setup on Kentico 10:
* Field Settings
* Email notification
* Result

0 votesVote for this answer Mark as a Correct answer

Dion Gee answered on May 28, 2020 13:34

Sure, hope this helps.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on May 28, 2020 13:40

Please, try removing the extra spaces around Department, so the macro is just like: {%Department%}
Then, also check the email queue - maybe the emails are being generated and are just not being sent for some reason - there could be an error message or something in the Event log too.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.