Friday, October 06, 2006 10:06 AM
Another handy little script
I have managed to work out a way in which you can save the form xml directly to the xml document within MOSS. Thereby, avoiding the complexities of flattening your schema for workflow integration (if you use it) and making the control of your form much more open to the developer rather than being horribly restricted to the wizards within InfoPath.
Please note that this will only work for InfoPath Forms Services, not within the InfoPath client.
public void saveData()
// save all the xml data directly to the document
String host = HttpContext.Current.Request.Url.DnsSafeHost;
SPSite site = new SPSite("http://" + host);
SPWeb web = site.OpenWeb();
String formUri = this.Uri.ToString();
SPListItem listItem = web.GetListItem("http://" + host + formUri);
// need to make a byte array
byte fileBytes = Encoding.ASCII.GetBytes(this.MainDataSource.CreateNavigator().OuterXml);
SPFile file = listItem.File;