3

We have a form on our JSS site's home page. When submitted, it uses sitecore's built in "Save data" action. However, it looks like when you submit the form multiple times, all rows in the FieldData table are linked back to the same form entry row via the FormEntryId column: formEntries & fieldData top table is form entry after two form submissions, bottom is field data.

This makes it impossible to separate the field data across different form submissions. Is there a setting I'm missing that would allow a new FormEntry row to be inserted per form submission?

Update: It looks like this only happens when the form is submitted multiple times between page loads. Refreshing the page and submitting the form again creates a new form entry.

2
  • I would assume there is new entry but FormId will be the same because its the same form Dec 30 '20 at 20:36
  • @JonKoivula It makes sense for FormDefinitionId to be the same, but the issue for me is that a new form entry row isn't added after the form is submitted (with new data) a second time
    – apoteet
    Dec 30 '20 at 20:58
1

The SavePostedData method in the Sitecore.ExperienceForms.Processing.Actions.SaveData class is responsible to construct the FormEntry object and store it using the defined FormDataProvider. The FormEntryId of the FormEntry object is initialized with the form SessionId.

The form SessionId, also rendered on the form's fxb_<formId>_FormSessionId hidden input field value, is initiated with a random new ID for every page request (implemented in Load method in Sitecore.ExperienceForms.Mvc.Controllers.FormBuilderController class):

this.FormRenderingContext.SessionId = ID.NewID.ToClientIdString();

To answer your question, there isn't a setting to override this implemented behavior. The assumption (and best practice) behind this implementation is that when a successful form submission occurs, the user would be redirected to a new page (using the OOTB RedirectToUrl submit action) or a success message would be rendered on the page in place of the form (rendering a second form page with the success message).

When rendering a success message, you have the option to include a link to the current page in the message to invite the user to enter a new form submission, that would reload the page upon clicking it.

1
  • Thank you for the insight, Alessandro, it's good to know what the expected behavior would be. Unfortunately, the idea of the form is that it can be quickly submitted and dismissed without a time-consuming reload. I normally wouldn't even expect a user to try to submit the form a second time...but if they did, it would be impossible to separate the first form submission from the second, since they share form entry id, and there are no timestamps to distinguish them.
    – apoteet
    Jan 5 at 5:30
0

There's probably a more direct solution to the problem, but I got around this by writing a custom submit action to save the form entry and field data rows to the db with a unique guid each time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.