From 64384608f1f2104917f412e33dc4fdab966cdefc Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 4 Sep 2025 08:41:11 -0500 Subject: [PATCH 1/7] Document loading records from submitted forms Added details for how to get the submitted record in a view file. --- .../developer/working-with-data.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/16/umbraco-forms/developer/working-with-data.md b/16/umbraco-forms/developer/working-with-data.md index eb4ef07555a..7894ae433ce 100644 --- a/16/umbraco-forms/developer/working-with-data.md +++ b/16/umbraco-forms/developer/working-with-data.md @@ -110,3 +110,43 @@ Sample script that is outputting comments using a Form created with the default } ``` + +## Loading a Record From a Submitted Form +When a form is submitted, the submitted form id as well as the saved record id is stored in the TempData so it can be referenced. + +You can use the FormService and the RecordStorage to get the ```Form``` and ```Record``` objects. + +Here is sample code for how to get the record in a view. + +``` +@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; + string submittedEmail; + + 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); + + submittedEmail = record.GetRecordFieldByAlias("email")?.ValuesAsString(); + } + } +} +``` From b0ee4ed1faa9d60f0b79420989d6559ba86d3ce4 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 4 Sep 2025 08:51:29 -0500 Subject: [PATCH 2/7] Shorten sentence --- 16/umbraco-forms/developer/working-with-data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/16/umbraco-forms/developer/working-with-data.md b/16/umbraco-forms/developer/working-with-data.md index 7894ae433ce..c77582f42d0 100644 --- a/16/umbraco-forms/developer/working-with-data.md +++ b/16/umbraco-forms/developer/working-with-data.md @@ -112,7 +112,7 @@ Sample script that is outputting comments using a Form created with the default ``` ## Loading a Record From a Submitted Form -When a form is submitted, the submitted form id as well as the saved record id is stored in the TempData so it can be referenced. +When a form is submitted, the submitted form id and the saved record id is stored in the TempData so it can be referenced. You can use the FormService and the RecordStorage to get the ```Form``` and ```Record``` objects. From d9972485f6b5d5f913d362020da5914c968576dc Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 4 Sep 2025 08:52:51 -0500 Subject: [PATCH 3/7] Add example for loading submitted form records Added sample code for loading a record from a submitted form using FormService and RecordStorage. --- .../developer/working-with-data.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/13/umbraco-forms/developer/working-with-data.md b/13/umbraco-forms/developer/working-with-data.md index efc171cb19e..75657d3c398 100644 --- a/13/umbraco-forms/developer/working-with-data.md +++ b/13/umbraco-forms/developer/working-with-data.md @@ -110,3 +110,45 @@ Sample script that is outputting comments using a Form created with the default } ``` + + +## Loading a Record From a Submitted Form +When a form is submitted, the submitted form id and the saved record id is stored in the TempData so it can be referenced. + +You can use the FormService and the RecordStorage to get the ```Form``` and ```Record``` objects. + +Here is sample code for how to get the record in a view. + +``` +@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; + string submittedEmail; + + 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); + + submittedEmail = record.GetRecordFieldByAlias("email")?.ValuesAsString(); + } + } +} +``` + From 7156a668bcd24f19bdae3bf846f4d115bf02ae4b Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 9 Sep 2025 07:29:39 -0500 Subject: [PATCH 4/7] Update 13/umbraco-forms/developer/working-with-data.md Co-authored-by: Ronald Barendse --- 13/umbraco-forms/developer/working-with-data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/13/umbraco-forms/developer/working-with-data.md b/13/umbraco-forms/developer/working-with-data.md index 75657d3c398..377ae5d2623 100644 --- a/13/umbraco-forms/developer/working-with-data.md +++ b/13/umbraco-forms/developer/working-with-data.md @@ -134,9 +134,9 @@ Here is sample code for how to get the record in a view. Record? record; string submittedEmail; - if (TempData["UmbracoFormSubmitted"] != null) + if (Guid.TryParse(TempData["UmbracoFormSubmitted"]?.ToString(), out Guid formId) && + Guid.TryParse(TempData["Forms_Current_Record_id"]?.ToString(), out Guid recordId)) { - Guid.TryParse(TempData["UmbracoFormSubmitted"]?.ToString(), out formId); form = _formService.Get(formId); From e0109322a5fefd263e9c338ca73d9964cd8e4fd9 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 9 Sep 2025 07:30:05 -0500 Subject: [PATCH 5/7] Update 16/umbraco-forms/developer/working-with-data.md Co-authored-by: Esha Noronha <82437098+eshanrnh@users.noreply.github.com> --- 16/umbraco-forms/developer/working-with-data.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/16/umbraco-forms/developer/working-with-data.md b/16/umbraco-forms/developer/working-with-data.md index c77582f42d0..ec5564f0e37 100644 --- a/16/umbraco-forms/developer/working-with-data.md +++ b/16/umbraco-forms/developer/working-with-data.md @@ -112,11 +112,11 @@ Sample script that is outputting comments using a Form created with the default ``` ## Loading a Record From a Submitted Form -When a form is submitted, the submitted form id and the saved record id is stored in the TempData so it can be referenced. +When a form is submitted, the submitted form ID and the saved record ID are stored in the `TempData` so they can be referenced. -You can use the FormService and the RecordStorage to get the ```Form``` and ```Record``` objects. +You can use the FormService and the RecordStorage to get the `Form` and `Record` objects. -Here is sample code for how to get the record in a view. +Here is a sample code for retrieving a record in a view. ``` @using Umbraco.Forms.Core.Models From 35a61b61246967cf6c83e641e0187ff6e08306fd Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 9 Sep 2025 07:30:13 -0500 Subject: [PATCH 6/7] Update 13/umbraco-forms/developer/working-with-data.md Co-authored-by: Esha Noronha <82437098+eshanrnh@users.noreply.github.com> --- 13/umbraco-forms/developer/working-with-data.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/13/umbraco-forms/developer/working-with-data.md b/13/umbraco-forms/developer/working-with-data.md index 377ae5d2623..9828140c772 100644 --- a/13/umbraco-forms/developer/working-with-data.md +++ b/13/umbraco-forms/developer/working-with-data.md @@ -113,11 +113,11 @@ Sample script that is outputting comments using a Form created with the default ## Loading a Record From a Submitted Form -When a form is submitted, the submitted form id and the saved record id is stored in the TempData so it can be referenced. +When a form is submitted, the submitted form ID and the saved record ID are stored in the `TempData` so they can be referenced. -You can use the FormService and the RecordStorage to get the ```Form``` and ```Record``` objects. +You can use the FormService and the RecordStorage to get the `Form` and `Record` objects. -Here is sample code for how to get the record in a view. +Here is a sample code for retrieving a record in a view. ``` @using Umbraco.Forms.Core.Models From 57143556d0218470aff2c8a9aec5e99bd1f87b73 Mon Sep 17 00:00:00 2001 From: Esha Noronha <82437098+eshanrnh@users.noreply.github.com> Date: Wed, 10 Sep 2025 12:29:48 +0200 Subject: [PATCH 7/7] Update 16/umbraco-forms/developer/working-with-data.md --- 16/umbraco-forms/developer/working-with-data.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/16/umbraco-forms/developer/working-with-data.md b/16/umbraco-forms/developer/working-with-data.md index ec5564f0e37..b5d42a577bf 100644 --- a/16/umbraco-forms/developer/working-with-data.md +++ b/16/umbraco-forms/developer/working-with-data.md @@ -133,9 +133,9 @@ Here is a sample code for retrieving a record in a view. Record? record; string submittedEmail; - if (TempData["UmbracoFormSubmitted"] != null) + if (Guid.TryParse(TempData["UmbracoFormSubmitted"]?.ToString(), out Guid formId) && + Guid.TryParse(TempData["Forms_Current_Record_id"]?.ToString(), out Guid recordId)) { - Guid.TryParse(TempData["UmbracoFormSubmitted"]?.ToString(), out formId); form = _formService.Get(formId);