I'm using the XmlFormView in a SharePoint page to view InfoPath browser enabled forms and programmatically add some opening and saving logic.
All goes fine, without the XmlForm.SaveAs method. This method throws an NotImplementedException if I call it on an instantiated XmlForm and with a valid location, see code:
ASPX:
<InfoPath:XmlFormView ID="infoPathFormView" ShowHeader="false" Style="width: 100%;" runat="server" />
Code behind:
infoPathFormView.SaveLocation = "http://localhost/MyFormLibrary";
infoPathFormView.DataBind();
if(infoPathFormView.XmlForm.New)
{
string fileName = Page.User.Identity.Name;
infoPathFormView.XmlForm.SaveAs(fileName); // This line throws.
}
else
{
infoPathFormView.XmlForm.Save();
}
Resulting in the following exception and stacktrace:
The method or operation is not implemented. at Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost.SaveAs(String fileUrl) at MyProject.ShowInfoPathForm.SaveButton_Click(Object sender, EventArgs eventArguments)
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
For clarity, I found that Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost is an internal class that inherits from the abstract XmlForm class.
- Does anyone have an idea why this piece of code is throwing a NotImplementedException?
- Is there a workaround to be able to save the XmlForm with the specified filename?
Thanks in advance!!