umbracoumbraco-contour

Hook into Umbraco Forms submission


I want to check for an existing record with the email address before submitting the form and saving the record. I did some research and most suggested using RecordService.RecordSubmitted event, however when I checked the Form.Core.Services I couldn't see any RecordService.

Is there any alternative way to hook into that event.

I am using Umbraco 7.4.3 and forms 4.3.2


Solution

  • You have a few options. One is to use one of the record storage events. these are contained in the following namespace:

    Umbraco.Forms.Data.Storage.RecordStorage
    

    The following events are available:

    I'm not 100% sure if you can delete the record in the RecordInserting event, as it may not be in the DB at that point, I've not actually tried.

    The other option would be to write a custom workflow that runs once the record is inserted that looks for duplicates and deletes the record if it's a duplicate. there is some documentation for this on the Umbraco Community site.

    Finally, you could create some custom validation that searches for existing records with that email address and wire it in using JQuery or similar, and just not submit the form if the validation fails.