Copied to clipboard

Flag this post as spam?

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


  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 03, 2010 @ 14:02
    Tim
    0

    Bug in RecordsViewer GetRecords Method

    Hi,

    There appears to be a bug in the GetRecords method of the RecordsViewer. If you call it and pass in the page id of the page you want the records for, you get all of the records for the form, not just the ones for the umbraco page that you specified. All of the Record objects that are returned are missing the umbraco page id, this apears to be because the code in the Record.CreateFromXMLRecord() method doesn't actually add it to the object.

    If you want to try and repo, create a form, add some approved entries from several pages, and then run the following code (note, you'll need to modify this to get it to work, as its an excerpt from a bigger page):

      int pageId = Convert.ToInt32(lstEvents.SelectedValue);
      List<Umbraco.Forms.Core.Enums.FormState> states = new List<Umbraco.Forms.Core.Enums.FormState>();
      states.Add(Umbraco.Forms.Core.Enums.FormState.Approved);

      FormStorage fs = new FormStorage();
      Form form = fs.GetForm(formId);
      fs.Dispose();

      RecordsViewer rv = new RecordsViewer();
      List<Record> list = rv.GetRecords(10000, pageId, form, Sorting.ascending, states);

      foreach (Record pie in list)
      {
       Response.Write(pie.UmbracoPageId.ToString() + "<br/>");
      }
      
      rv.Dispose();

    All of the page ids are zero, and you'll see that all of the entries are returned, not just the ones for the specified page.

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 05, 2010 @ 11:45
    Tim
    0

    After a bit more testing, ALL of the methods in the RecordsViewer that get Record objects are afflicted by this issue (presumably because they all call the CreateFromXMLRecord() method. There was an older version of Contour that you could actualy open in Reflector and I've had a dig around, and if the code hasn't changed, it's missing the line to add the UmbracoPageId (most of the other fields seem to be added).

    Another thing I spotted is that if you call the  GetRecords(int maxNumber, int page, Form form) method, it doesn't actually honour the page that you pass in it just passed in the form.

    Hope that helps!

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 13, 2010 @ 21:04
    Tim
    0

    Is there any chance of getting this into 1.1.4?

    :)

  • Comment author was deleted

    Nov 15, 2010 @ 08:49

    Yup working on 1.1.4 this week, will make sure this get's fixed

  • Comment author was deleted

    Nov 15, 2010 @ 13:18

    Hi Tim,

    Looks like GetPagedXmlRecords is the method you are looking for

  • Comment author was deleted

    Nov 15, 2010 @ 13:20

    The getrecords methods are older methods that aren't used anymore

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 15, 2010 @ 13:38
    Tim
    0

    Ahhh, ok. I couldn't get the PagedXmlRecords to bind to a datagrid properly, so was using the ones that returned records!

  • Comment author was deleted

    Nov 15, 2010 @ 13:44

    Try enclosing the call with XmlHelper.XmlToRecords()

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Nov 15, 2010 @ 13:45
    Tim
    0

    Awesome, I'll give that a go this afternoon! Thanks.

    :)

Please Sign in or register to post replies

Write your reply to:

Draft