I have a custom section in the backoffice in which I get all records from a form and display them. This however, is painfully slow even with as low as 10 records.
But if you just view the records in Contour's own section in the back-office, that just works lightning fast.
Is there another way of retrieving these records that's faster I am missing?
DynamicRecordList records = Library.GetRecordsFromForm(eventID);
// GET THE ORIGNAL LIST OF RECORDS
IEnumerable<DynamicRecord> recordsItems = records.Items.Where(x => x.State.ToString() == "Approved");
and then further down I loop through them
foreach (var item in recordsItems)
{
RecordStorage storage = new RecordStorage();
Record record = storage.GetRecord(new Guid(item.Id));
var recordFields = record.RecordFields; //.OrderBy(r => r.Value.Field.PageIndex).ThenBy(r => r.Value.Field.FieldsetIndex).ThenBy(r => r.Value.Field.SortOrder);
string naam = "";
string email = "";
string evenementnaam = "";
string evenementcode = "";
foreach (var field in recordFields)
{
//FULLNAME
if (field.Value.Field.Caption.ToLower() == "achternaam" || field.Value.Field.Caption.ToLower() == "tussenvoegsel" || field.Value.Field.Caption.ToLower() == "voornaam")
{
naam += field.Value.ValuesAsString() + " ";
}
if (field.Value.Field.Caption.ToLower() == "e-mailadres")
email = field.Value.ValuesAsString();
if (field.Value.Field.Caption.ToLower() == "evenementnaam")
evenementnaam = field.Value.ValuesAsString();
if (field.Value.Field.Caption.ToLower() == "evenementcode")
evenementcode = field.Value.ValuesAsString();
}
Thanks for the tip Tim. That got me started in the right direction. If anybody has to do this, keep in mind that you'll be getting back json with this snippet.
I'm doing a similar thing where I need to find records that were submitted from a particular pageID, I'm having trouble finding the recordsViewer(), I'm using umbraco 7.3.8, any help would be appreciated
I'm also looking for a light-weight entry-fetcher since Library.GetRecordsFromForm is way too slow and RecordsViewer seem to be obsolete.
Umbraco version: 7.5.3, Forms version: 4.3.2.
If anyone else is struggling with this, here's the solution I came up with. It reduced the time for
fetching 700 form entries from 15 seconds to 1!
Short summary:
Use the GetAllRecords method and set its second parameter (includeFields) to false.
Get the content of custom fields by deserializing the record's RecordData property.
Here's the code:
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Umbraco.Forms.Core;
using Umbraco.Forms.Data.Storage;
using Umbraco.Web;
using Umbraco.Web.Mvc;
/***************************************************************************/
using (var formStorage = new FormStorage())
{
using (var recordStorage = new RecordStorage())
{
// Get form by guid
var form = formStorage.GetForm(formGuid));
// Get all form records. Note the second, includeFields, parameter of the GetAllRecords method.
List<Record> recordList = recordStorage
.GetAllRecords(form, false)
.OrderBy(x => x.Created)
.ToList();
// Iterate over the records
foreach (Record record in recordList)
{
// Get content of current entry's all custom fields
string jsonData = record.RecordData.ToString();
// Deserialize the json objects (guid/value) to a Dictionary's key/value pair
Dictionary<string, string> fieldsDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonData);
// Get state
string approved = record.State.ToString();
// Get first name (custom field)
string firstName = fieldsDictionary[fieldGuidFirstName];
//*********************************************************************************
// The part where the custom fields content is assigned to a custom object, which
// in turn is added to a list, is removed here for readability reasons.
}
}
}
Umbraco forms library slow in back-end
Hey guys,
I have a custom section in the backoffice in which I get all records from a form and display them. This however, is painfully slow even with as low as 10 records.
But if you just view the records in Contour's own section in the back-office, that just works lightning fast.
Is there another way of retrieving these records that's faster I am missing?
DynamicRecordList records = Library.GetRecordsFromForm(eventID);
and then further down I loop through them
}
Comment author was deleted
Yeah the records viewer works with the tranformed records xml, maybe this code snippet can get you started
Thanks for the tip Tim. That got me started in the right direction. If anybody has to do this, keep in mind that you'll be getting back json with this snippet.
Comment author was deleted
Great, glad it was helpful!
Hi Giovanni, Tim
I'm doing a similar thing where I need to find records that were submitted from a particular pageID, I'm having trouble finding the recordsViewer(), I'm using umbraco 7.3.8, any help would be appreciated
Regards Brendan
The RecordsViewer class does not seem to exist in my Forms 6.0.2 installation. Has this been replaced with something else?
I'm also looking for a light-weight entry-fetcher since Library.GetRecordsFromForm is way too slow and RecordsViewer seem to be obsolete. Umbraco version: 7.5.3, Forms version: 4.3.2.
If anyone else is struggling with this, here's the solution I came up with. It reduced the time for fetching 700 form entries from 15 seconds to 1!
Short summary:
Here's the code:
is working on a reply...