Record displayed value on form submit

kyle shapiro asked on April 13, 2015 18:20

I am using value;displayText on a dropdown list for one of my forms. I am using the solution found at https://devnet.kentico.com/articles/how-to-send-form-notifications-to-different-emails-based-on-field-values for emailing a certain person depending on which dropdown is selected. This looks like myEmail@gmail.com;Option1. The displayed text for the dropdownlist option is "Option1" but when submitted, the form emails to myEmail@gmail.com (the value). The problem with this, is that when I look at recorded data for submitted forms, myEmail@gmail.com is saved for that field instead of Option1. Is there a Portal engine solution to have Option1 recorded instead of myEmail@gmail.com ?

Correct Answer

kyle shapiro answered on April 17, 2015 18:34

I came up with a solution for this that worked for me, and wanted to share it in case someone else has the same problem. First I set the dropdown list to populate from the database, selecting the values I wanted to be displayed to the customers for both the value and displayed value field. Then I added a second dropdownlist to the form that I set dependent on the first one. It is populated with a query that has a macro in it that grabs the value from original dropdownlist {% OriginalDBList @%}. This query selects the desired email address, and returns it as both the value and display value. I already had a custom layout, so I did not add this 2nd dependent dropdownlist to display. Then I added the value from the 2nd dropdownlist to the email recipient field in Email Notification {% dependant2ndDBList @%}. This way I use already existing tables, and don't have to create any custom macros.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Charles Matvchuk answered on April 13, 2015 19:35

Excellent question, I was looking into the same thing this morning. I have yet to find a solution.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on April 13, 2015 20:40

You have to create custom table with appropriate fields: id|email|text, and use its records for drop down. Also you have to implement custom macro which will fetch either email or text value from custom table for you.

1 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on April 13, 2015 20:47

Apparently I read the question wrong, Romans answer works in this scenario, I was trying to do something else.

0 votesVote for this answer Mark as a Correct answer

Jim Spillane answered on April 14, 2015 02:28

You can try using a delimiter to store both the email and display text, like the colon below...

info@company.com:General;General
sales@company.com:Sales;Sales
support@company.com:Support;Support

Then, to get the individual stored values use Split() to get the email and display text respectively...

{% category.Split(":")[0] %}
{% category.Split(":")[1] %}
2 votesVote for this answer Mark as a Correct answer

kyle shapiro answered on April 14, 2015 20:06

Hi everyone, thanks for the replies. Both of these solutions seem good, but where can I put the custom macro? I don't see a location to place it. I'm trying to control what is going into the database / Recorded Data.

0 votesVote for this answer Mark as a Correct answer

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