I
ISUComSciGuy
I am trying to add a custom save button at the end of my forms. The code is
as follows:
--------------------------------------------------------------------
function XDocument::OnSaveRequest(eventObj)
{
var header = "file:///";
var drive = "C:/";
var mainFolder = "Electronic%20Forms/Completed%20Forms/";
XDocument.UI.Alert("at 1"); // Debug code
var filePath = header + drive + mainFolder;
var fileName = "test.xml";
var fileURL = filePath + fileName;
XDocument.UI.SetSaveAsDialogLocation(filePath);
XDocument.UI.SetSaveAsDialogFileName(fileName);
XDocument.UI.Alert(fileURL); // debug code
eventObj.IsCancelled = eventObj.PerformSaveOperation();
if (eventObj.IsCancelled)
{
XDocument.UI.Alert("Save Cancelled");
}
eventObj.ReturnStatus = true;
XDocument.UI.Alert("Form saved.");
}
function CTRL85_5::OnClick(eventObj)
{
XDocument.Save();
}
--------------------------------------------------------------------
If I save the form using the save command on the toolbar or File menu, the
SaveAs dialog box appears with the correct file path and file name. However,
when I call the XDocument.Save() command in the OnClick() event handler of
the button I get the following error message:
--------------------------------------------------------------------
The following error occurred:
InfoPath cannot save the form.
The OnSaveRequest function returned a value indicating that the save failed.
The following error occurred:
The form does not have a file name.
File:script.js
Line:71
File:script.js
Line:90
--------------------------------------------------------------------
as follows:
--------------------------------------------------------------------
function XDocument::OnSaveRequest(eventObj)
{
var header = "file:///";
var drive = "C:/";
var mainFolder = "Electronic%20Forms/Completed%20Forms/";
XDocument.UI.Alert("at 1"); // Debug code
var filePath = header + drive + mainFolder;
var fileName = "test.xml";
var fileURL = filePath + fileName;
XDocument.UI.SetSaveAsDialogLocation(filePath);
XDocument.UI.SetSaveAsDialogFileName(fileName);
XDocument.UI.Alert(fileURL); // debug code
eventObj.IsCancelled = eventObj.PerformSaveOperation();
if (eventObj.IsCancelled)
{
XDocument.UI.Alert("Save Cancelled");
}
eventObj.ReturnStatus = true;
XDocument.UI.Alert("Form saved.");
}
function CTRL85_5::OnClick(eventObj)
{
XDocument.Save();
}
--------------------------------------------------------------------
If I save the form using the save command on the toolbar or File menu, the
SaveAs dialog box appears with the correct file path and file name. However,
when I call the XDocument.Save() command in the OnClick() event handler of
the button I get the following error message:
--------------------------------------------------------------------
The following error occurred:
InfoPath cannot save the form.
The OnSaveRequest function returned a value indicating that the save failed.
The following error occurred:
The form does not have a file name.
File:script.js
Line:71
File:script.js
Line:90
--------------------------------------------------------------------