Andy Weeks
skipping stones Posts:5
|
10-31-2011 12:21 PM |
|
Hi,
We would like to have a completion event which triggers an email -- but only if the email address in the registration form is not already an email address for a user in the Registered User role for the portal.
We do not want to use the checkbox to only allow unique email addresses for registering. [Users can be added to the portal through a custom application -- but they are not aware of their username. We still want them to be able to register with an email address that already exists so they can interact with the website using the username they create.]
We have tried a few solutions. Here is the latest. We have a hidden field which populates a dnn core field of "EmailExists." We default this to false. Then, we create a sql completion event which fires first which updates the value of this field for the user based on whether there already exists a user in the Registered Users role with the same email. This all works fine. If the user exists, this is updated to true.
Then, in the email completion event, we trigger the email only if the EmailExists field is equal to false (really 0). However, it seems that the code uses the cached value for this field from registration as opposed to the current value in the db. [The term it uses is "User Response" which would make sense.]
Is there another way to skin this cat here so we can only fire the email to a new user if their email address has not yet been added to the portal?
Thanks,
Andy Dynamic Registration v. 4.10.13 |
|
|
|
|
Candace
river guide Posts:2431
|
10-31-2011 03:01 PM |
|
Hi Andy, First thing would be to make sure that you're on the latest build so I would suggest you get Dynamic Registration 4.1.70 in your Snowcovered account under Patches and Hotfixes (or in MyDownloads if you have the Collection or the User Management Suite 2.0). Next, can you confirm that this field is not mapped to a profile property? Also, when you're testing are you logged in as an Admin/Host? Do you get the same behavior if you're testing as a regular user? Thanks! Candace
|
|
|
|
|
Don Gee
river guide Posts:273
|
10-31-2011 10:03 PM |
|
Hi Andy, On the matter of a solution I would say you might consider a sql solution. See if the following idea helps: Create a stored procedure in the database that accepts the value of the Registration Form's email value as a string parameter. The stored procedure will check the USERS table by using a select count for this parameter value being equal to all email values in the USERS table. Then the stored procedure returns "FALSE" as default return value and "TRUE" if the return value if count > 0. Stored Proc fires before form submission after email value is entered. Maybe you make user double enter Email and check that both are same. Then also have a hidden field in the Dynamic Registration form that has a default value of "TRUE". You will set your hidden field to FALSE if return value from stored proc is "TRUE". What should happen is that the email completion event will fire on form submission and send an email based on hidden field value of "TRUE". That means it is TRUE that this email not yet in the USERS table. This kind of complex but it is a possible solution. Thanks |
|
|
|
|
Andy Weeks
skipping stones Posts:5
|
11-01-2011 07:43 AM |
|
Hi Candace,
The field that I used to trigger the email completion event (EmailExists) is mapped to a profile property. That is how I am updating it using a SQL completion event first. I am testing by registering as a new user -- beginning as an anonymous user. I am not testing with Admin/Host.
I will certainly get the latest build.
Thanks for your response. I am going to try the solution suggested below yours because it is an easy one to test.
Andy |
|
|
|
|
Andy Weeks
skipping stones Posts:5
|
11-01-2011 07:49 AM |
|
Hi Don,
The reason I didn't try this was because the sql-based default value for a field doesn't indicate that it accepts tokens -- as it does for a sql completion event. It's unclear to me what events trigger the sql-based default value to be updated. In other words, if you set a non-hidden field with a sql-based default value, that value will display before the user begins entering information for other fields. So, it is unclear if the sql will be updated after the user enters an email address. However, there's one way to find out, so I will give it a try and let you know.
Andy |
|
|
|
|
Andy Weeks
skipping stones Posts:5
|
11-01-2011 09:38 AM |
|
I tried this approach with no luck. The sql-based default value for a field does not seem to want to use the token values of the shortname from another value in the form (email in this case).
I looked into a question event, but there is no option in there to set a default value based on a sql statement.
Any other ideas? |
|
|
|
|
Don Gee
river guide Posts:273
|
11-01-2011 11:53 AM |
|
Hi Andy, Well then lets see. Whatever you do in a form like with hidden fields for storing values or using tokens do it different if they are the problem. Like put the values in a flat table where you may need only one record and it has values in different columns for what you are keeping and you store your different values to different columns in this record or update them as needed. Then couldn't you supply those values through a query to a default value in the form and bypass the need for storing values in a hidden field or accessing tokens. In the end of the process you will probably still use a hidden field to store a flag for your email completion event though. The stored proc may get more complicated than what I first proposed but wouldn't something like this be possible?
|
|
|
|
|
Don Gee
river guide Posts:273
|
11-01-2011 12:40 PM |
|
Hi Andy, I overlooked something you said above in my reply and I wanted to add something. The process should go as follows: 1. Get input text box from user for an email value 2. After 1. above fire the stored proc/database solution. The end of the process will trip or not trip a flag in the form. Your email completion event depends on a field is easy to trigger off of a form field value. I think you can get the stored procedure to fire and even set a value in the form after the form loads if it is set up to be called in the Module Configuration area. Thanks |
|
|
|
|
Andy Weeks
skipping stones Posts:5
|
11-02-2011 11:24 AM |
|
Hi Don,
I wish I could say I follow your entire reply, but I'm a little lost.
"Get input text box from user for an email value." - I am presuming this just means make sure Email is one of the values in the form, which is it (by default).
"After 1 above, fire the stored procedure solution." I'm not sure how to fire an event like you describe. In this case, I would want it to retrieve a value using a sql query (or stored proc), and then use that value in another (hidden) form field. I am not finding anything in the config which would allow me to accomplish this.
You reference the Module Configuration area for triggering the stored proc. Does this mean this should be triggered using javascript upon form save / submit in Module Configuration? If so, would you have a code sample that could call a simple stored proc and update a form field?
Many thanks,
Andy
|
|
|
|
|