Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > K# macro in notification email field View modes: 
User avatar
Member
Member
Jerreck - 1/28/2014 10:44:05 AM
   
K# macro in notification email field
I'm creating a contact form in CMS Desk > Tools > Forms.

The form has a field whose name is "Topic" and field type is radio button with three options:

1;General comment
2;Website comment
3;Website problem


When this form is submitted, I want its data to be sent to one of two email addresses based on the value of the selected radio button.

I'm using the following macro to populate the to-email field under the Notification Email tab:

{% Topic == 1 || 2 ? "email1@example.com" : "email2@example.com" %}


The expression always evaluates to false and sends an email to email2, even if I select the radio button value 1.

The ternary operator works when I use mathematical expressions like 4 + 4 = 9, which evaluates to false and sends an email to email2, or 2+2 = 4 which evaluates true and sends an email to email1, so I'm thinking the problem is that the Topic field is not resolving.

Anyone care to take a guess at what my issue is?

User avatar
Kentico Legend
Kentico Legend
Accepted solutionAccepted solution
Brenden Kehren - 1/28/2014 9:15:57 PM
   
RE:K# macro in notification email field
Have you looked at the Macro Expressions docs? I think your OR statement is incorrect. I think it should read
{% Topic == 1 || Topic == 2 ? "email1@example.com" : "email2@example.com" %}

User avatar
Member
Member
Jerreck - 1/28/2014 10:48:27 PM
   
RE:K# macro in notification email field
I guarantee you that you're right. Looking at it now that I'm not at work, I had my statement written incorrectly. I was saying "if topic is equal to 1 OR if 2" and not "if topic is equal to 1 OR if topic is equal to 2". Classic noobie logic mistake :(

I'll post again tomorrow to confirm.