Working With Record Data
Developer documentation on working with Forms record data.
Umbraco Forms includes some helper methods that return records of a given Form, which can be used to output records in your templates using razor.
Available Methods
The methods can be found by injecting the Umbraco.Forms.Core.Services.IRecordReaderService
interface. For performance reasons, all these methods are paged.
GetApprovedRecordsFromPage
Returns all records with the state set to approved from all Forms on the Umbraco page with the id = pageId
.
GetApprovedRecordsFromFormOnPage
Returns all records with the state set to approved from the Form with the id = formId
on the Umbraco page with the id = pageId
as a PagedResult<IRecord>
.
GetApprovedRecordsFromForm
Returns all records with the state set to approved from the Form with the ID = formId
as a PagedResult<IRecord>
.
GetRecordsFromPage
Returns all records from all Forms on the Umbraco page with the id = pageId
as a PagedResult<IRecord>
.
GetRecordsFromFormOnPage
Returns all records from the Form with the id = formId
on the Umbraco page with the id = pageId
as a PagedResult<IRecord>
.
GetRecordsFromForm
Returns all records from the Form with the ID = formId as a PagedResult<IRecord>
.
The returned objects
All of these methods will return an object of type PagedResult<IRecord>
so you can iterate through the IRecord
objects.
The properties available on a IRecord
are:
In order to access custom Form fields, these are available in the RecordFields
property. Furthermore there exists an extension method named ValueAsString
on IRecord
in Umbraco.Forms.Core.Services
, such that you can get the value as string given the alias of the field.
This extension method handle multi value fields by comma separating the values. E.g. "A, B, C"
Sample razor script
Sample script that is outputting comments using a Form created with the default comment Form template.
Last updated