How to get posted data from forms

Vote:
 
I'm trying to get the posted data from some XForms using the GetPostedData method. I get no data although I know there is data available. I can see it using the appropriate tab "formulärdata". How does one use this method. Sample code, lbOutput is an asp:ListBox just for testing. object[] folders = (object[])XFormFolder.GetForms(); lbOutput.Items.Clear(); foreach(object o in folders) { if(o.GetType() == typeof(XForm)) { XForm xf=o as XForm; object[] al=(object[])xf.GetPostedData(); lbOutput.Items.Add(xf.FormName + " (" + al.Length.ToString() + ")"); foreach(object data in al) { if(data.GetType() == typeof(XFormData)) { XFormData xfData=(XFormData)data; lbOutput.Items.Add("[" + xfData.DatePosted.ToShortDateString() + "]"); } } lbOutput.Items.Add("------------------------------"); } } thanks for any answers.
#12774
Mar 25, 2008 18:35
Vote:
 
Hi Anders I think your problem is in your casting of types to objects, my test program has the same functionality as yours but uses typed values and it’s working fine. Eg. IList xforms = EPiServer.XForms.XFormFolder.GetForms(); foreach (EPiServer.XForms.XForm xform in xforms) { foreach (EPiServer.XForms.XFormData data in xform.GetPostedData()) { log4net.LogManager.GetLogger("").Debug(data.DatePosted); } } Regards, Mattias Lövström
#14875
Mar 25, 2008 18:46
Vote:
 
Hi, Your solutions above are exactly what I need, but I don't have EPiServer.XForms.XFormFolder class since I'm running 4.51. I checked the SDK for 4.60 and of course its there, but how do I do the same thing with 4.51. Here is the class reference for 4.51: http://www.episerver.com/Downloads/full/SDKEPiServer451.zip Tanks for any answers. Regards
#14876
Mar 25, 2008 18:46
Vote:
 
Hello! In 4.51 it's possible to extract form data directly from the DataAccess layer through the class EPiServer.DataAccess.XFormStatisticsDB. You should be aware that you might change this if you make an upgrade as this is a non-documented namespace that might change behaviour.
#14877
Mar 25, 2008 18:46
Vote:
 
Thanks for your help Linus! But I still don't get it. What I want is to make a (regular) page from where I can view and edit saved formdata. Pretty much like the "view saved form data" (Formulärdata-tab) in admin mode. So the page should exist of a dropdown with all the forms and a DataGrid with all the saved records from the selected form. The dropdown works fine: private void FormDropDownList_DataBinding(object sender, System.EventArgs e) { DropDownList ddl = sender as DropDownList; EPiServer.DataAccess.FormDefinitionDB fdDB = new EPiServer.DataAccess.FormDefinitionDB(); dd.DataSource = fdDB.GetALLForms(); } But how do I get all the stored records/postings for the selected form? By other words how do I write the DataBinding method for the DataGrid? The "DataSet EPiServer.DataAccess.FormStatisticsDB.GetStatistics(pageID, pageDefiniftionID, formDefenitionID)" is not what I look for since I only got formID and formGUID from the dropdown above. Thanks for any help. Regards
#14878
Mar 25, 2008 18:46
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.