API Questions on Kentico API.
Version 6.x > API > Use conditional from form as subject line in notification email View modes: 
User avatar
Member
Member
chris.worthington-barclayvouchers.co - 5/20/2013 9:12:52 PM
   
Use conditional from form as subject line in notification email
Hello,

I'm new to Kentico so I apologize if I'm posting this in the wrong forum.

Currently we have a form for inquiries and what we'd like to do is set the subject line to contain information based on the inquiry form.

We have a radio button option for their inquiry type; what we'd like to do is append their choice to the subject line in the email.

Something along these lines:

Inquiry type:
(button 1) SPAM request
(button 2) Annoying telemarketing request
(button 3) Intrusive drop-by request
(button 4) Request for free promotional goodies

Then append those choices to the inquiry email:

Subject line: Customer inquiry: SPAM request

Is there a way to use conditionals in the notification email function? I figured it would be something like:

InquiryType = button(x)
SubjectLine = "Customer inquiry: " + InquiryType

Any help would be greatly appreciated.

Thank you,
Chris

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 5/21/2013 2:10:19 AM
   
RE:Use conditional from form as subject line in notification email
Hi,

You can use context macros with forms notification emails. If you enter Customer Inquiry: {%Inquiry%} as notification email subject, the macro will resolve as the value selected for the field Inquiry.

Regards,
Josef Dvorak

User avatar
Member
Member
chris.worthington-barclayvouchers.co - 5/21/2013 2:43:08 AM
   
RE:Use conditional from form as subject line in notification email
Josef,

Thank you for your reply. It worked partially.

This is a field called "inquirycontents"
1;福利厚生用食事券をご検討中の企業さま
2;ご加盟をご検討中の飲食店さま
3;ご加盟店さま
4;その他お問い合わせ

When the user selects one, all we get is the number.

I tried {%inquirycontents[1]%} trying to use what I know in Python, but to no avail. Is there a way to swap the number with the value that follows it?

Thank you,
CW

User avatar
Member
Member
chris.worthington-barclayvouchers.co - 5/21/2013 3:01:40 AM
   
RE:Use conditional from form as subject line in notification email
Josef,

One more thing. I read the link you provided. Thank you for that.

They provided a lot of info and I'm learning about how Kentico works, but I still don't understand how to access the data I'm looking for.

As pointed out in the last post, the field "inquirytype" is either 1, 2, 3 or 4 with a choice after it. I know it's something like inquirytype.key, but I don't know the name of the key or how to find it.

Any additional help you can offer will be greatly appreciated.

Thank you,
Chris

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 5/21/2013 3:40:34 AM
   
RE:Use conditional from form as subject line in notification email
Hello,

Unfortunately this is not possible with the context macro, as it is able to access only the value from the saved form entry. It does not have access to the name of the option in the definition of the form field.

There are two ways to achieve what you need. Either put the same value and name to the selection options (SPAM request;SPAM request), or create a custom macro and resolve the values selected in inquirytype to any string you need in the code.

Regards,
Josef Dvorak

User avatar
Member
Member
chris.worthington-barclayvouchers.co - 5/21/2013 7:49:00 PM
   
RE:Use conditional from form as subject line in notification email
Josef,

How do I change it to use the first idea you suggested?

For example, under "Forms" -> Fields -> inquirycontents -> Options, I have this:

1;福利厚生用食事券をご検討中の企業さま
2;ご加盟をご検討中の飲食店さま
3;ご加盟店さま
4;その他お問い合わせ

Would I change these options to read like this?

1福利厚生用食事券をご検討中の企業さま;福利厚生用食事券をご検討中の企業さま
2ご加盟をご検討中の飲食店さま;ご加盟をご検討中の飲食店さま
3ご加盟店さま;ご加盟店さま
4その他お問い合わせ;その他お問い合わせ

or this?
1;(福利厚生用食事券をご検討中の企業さま;福利厚生用食事券をご検討中の企業さま)
2;(ご加盟をご検討中の飲食店さま;ご加盟をご検討中の飲食店さま)
3;(ご加盟店さま;ご加盟店さま)
4;(その他お問い合わせ;その他お問い合わせ)

I have to admit the latter looks better.

User avatar
Certified Developer 13
Certified Developer 13
kentico_josefd - 5/22/2013 1:22:05 AM
   
RE:Use conditional from form as subject line in notification email
Hello,

The third option is not a valid setting, only the first two examples would work. You do not need to include the numbers in the form if you do not need them for the form. The option can look like this:

福利厚生用食事券をご検討中の企業さま;福利厚生用食事券をご検討中の企業さま

Regards,
Josef Dvorak

User avatar
Member
Member
chris.worthington-barclayvouchers.co - 5/22/2013 1:24:07 AM
   
RE:Use conditional from form as subject line in notification email
Josef,

Thank you, I tried it and it works perfectly. After reading your comment a second time, I figured it out.

I thought the key had to be a single digit; I didn't realize the key could be multiple characters. I imagine it will require more space in the database but at least the mail form will work.

Thank you.