Microsoft Office Forums


Reply
Thread Tools Display Modes

Custom Save button (JScript) not working

 
 
ISUComSciGuy
Guest
Posts: n/a
 
      12-04-2007, 08:47 PM
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

--------------------------------------------------------------------



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a custom save button Pedro Innecco Infopath Newsgroup 1 01-23-2008 07:53 PM
Custom button to open the Save As dialog box Brian Pembroke Infopath Newsgroup 1 07-03-2007 07:32 AM
IP2007 : Custom Save Button (avoid validation rules) hurtlingturtle Infopath Newsgroup 1 08-16-2006 01:30 PM
Using a custom Save Button Lee Infopath Newsgroup 1 10-24-2005 05:36 PM
Why the save button is not working in debug mode? G. Tarazi Infopath Newsgroup 0 09-23-2004 05:08 PM



All times are GMT. The time now is 02:41 PM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92