Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Danny Winbourne 33 posts 54 karma points
    Oct 06, 2011 @ 17:12
    Danny Winbourne
    0

    Get all submitted records in code (not XLST)

    Hi,

    what is the easiest way to get all submitted records into a dataset of sorts?
    In XLST, you can use  umbraco.contour:GetRecordsFromForm but, I can't find how/where to use this in code?

    I have the following code, which does work, but I would rather fetch just the records for my specific form.

    Cheers in advanced,
    Danny

                Umbraco.Forms.Data.Storage.RecordStorage storage = new Umbraco.Forms.Data.Storage.RecordStorage();
             var allRecords = storage.GetAllRecords();

                List<Record> pollAnswers = new List<Record>();

                foreach (var record in allRecords)

                {

                    if (record.Form == new Guid(activePoll))

                        pollAnswers.Add(record);

                }

  • Comment author was deleted

    Oct 06, 2011 @ 17:17

    Hi Danny,

    Take a look at this: http://www.nibble.be/?p=102

    Wich are basicly some dynamic objects you can use, should make it easy

  • Danny Winbourne 33 posts 54 karma points
    Oct 06, 2011 @ 17:28
    Danny Winbourne
    0

    Hi Tim,

    Thanks for the quick response:

    ok, so I've tried:

                foreach (dynamic record in Library.GetRecordsFromForm(activePoll))

                {

                    string foo = record.Name;

                }

    it only loops once (I have 2 responses so far), and 'foo' is getting set to "uformrecords"

    Am I missing anything?

     

    Edit: I am doing this in the code-behind of a usercontrol, and not a cshtml file, so I can't use the razor markup.

  • Danny Winbourne 33 posts 54 karma points
    Oct 06, 2011 @ 18:41
    Danny Winbourne
    0

    Ok, Sorted now.

    I hadn't downloaded the dll (DOH!) and was using a different library object.

     

    Cheers

    Danny

  • Comment author was deleted

    Oct 07, 2011 @ 09:50

    great, glad it's working now

Please Sign in or register to post replies

Write your reply to:

Draft