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.
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.
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.
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!
Is there any chance of getting this into 1.1.4?
:)
Comment author was deleted
Yup working on 1.1.4 this week, will make sure this get's fixed
Comment author was deleted
Hi Tim,
Looks like GetPagedXmlRecords is the method you are looking for
Comment author was deleted
The getrecords methods are older methods that aren't used anymore
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
Try enclosing the call with XmlHelper.XmlToRecords()
Awesome, I'll give that a go this afternoon! Thanks.
:)
is working on a reply...