Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 849
Web pundit Avatar asked Mar 12 '23 16:03

Web pundit


1 Answers

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:

  • RecordDeleting
  • RecordFetching
  • RecordInserting
  • RecordUpdating

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.

like image 160
Tim Avatar answered May 10 '23 19:05

Tim