Umbraco Forms submitted record values on success page

I want to show the submitted values to the user on the form success page, however I can’t figure out a good way to get the submitted form values in the response view. I’m on Umbraco forms and Umbraco version 13.

I can see the form id and record id in the TempData, but the only way i can figure out how to get the records field values from that is to load all records form the form and loop through them to find things. My forms have thousands of entries so loading all records takes a while.

The RecordReaderService is only returning a handful of total records (like i have 180 and it only sees 11), and even if it returned everything, doing a pagination look up still isn’t ideal.

Are there any other ways to get the Umbraco Forms submitted values on the success page of the site?

I took inspiration from here….

Getting Submitted Form Data in Umbraco Forms

Though in the end decided hyjacking page view controllers, wasn’t all that extensible, so added a workflow that simply flagged the field that should be included in the tempData alongside the recordId/formId and overrode/hyjacked the UmbracoFormsController>OnFormHandled method

protected override void OnFormHandled(Form form, FormViewModel model)
{
  if (_workflowService.Get(form).FirstOrDefault(x => x.WorkflowTypeId == AddToTempDataWorkFlowType.Guid) is not Workflow workflow)
  { return; }
   …
    [ADD extra to the tempData Here]
TempData["{ALIAS}"] = "{some values/serialised values}";
  }
  
  base.OnFormHandled(form, model);

}

Hi @kevinm!

You should be able to do something along these lines to get the value…

@using Umbraco.Forms.Core.Models
@using Umbraco.Forms.Core.Persistence.Dtos
@using Umbraco.Forms.Core.Data.Storage
@using Umbraco.Forms.Core.Services
@inject IFormService _formService
@inject IRecordStorage _recordStorage
@inherits UmbracoViewPage
@{
	Guid formId;
	Form? form;
	Guid recordId;
	Record? record;

	if (TempData["UmbracoFormSubmitted"] != null)
	{
		Guid.TryParse(TempData["UmbracoFormSubmitted"]?.ToString(), out formId);

		form = _formService.Get(formId);

		if (form != null && TempData["Forms_Current_Record_id"] != null)
		{
			Guid.TryParse(TempData["Forms_Current_Record_id"]?.ToString(), out recordId);

			record = _recordStorage.GetRecordByUniqueId(recordId, form);
		}
	}
}

There may be better ways of null checking than this, but conceptually this is how you should be able to get these records on the success page.

@rickbutterfield thanks! That’s what i was looking for.

I could not find GetRecordByUniqueId() and didn’t think to look in the RecordStorage class.

Still feels wrong @inject into a view :face_with_peeking_eye: