SaveAs function

K

Koen Alleman

How do I change the default name "form1" when I save a form? I want it to be
a date which i've set in my form. Let's call it 'Field1'.

This is what I have:

var nodeselname =
XDocument.DOM.selectSingleNode("/my:myFields/my:Field1").text
XDocument.UI.SetSaveAsDialogFileName("nodeselname.text");
XDocument.UI.SetSaveAsDialogLocation("C:\temp\");

But this doesn't work. What I'm I doing wrong?
Can anyone give me the code (JScript)?
 
S

S.Y.M. Wong-A-Ton

Try removing the double quotes around "nodeselname.text" like this

XDocument.UI.SetSaveAsDialogFileName(nodeselname.text);

and try it again.
 
K

Koen Alleman

No, this doesn't work.
I get an error message saying something is wrong in my script (on line 36).
So I checked line 36 and it is this:
XDocument.UI.SetSaveAsDialogLocation("C:\temp\");

What's wrong with that?

If i remove this line and just use my SetSaveAsDialogFileName, it doens't
work either. The form opens, but when I try to save, it gives me the standard
name again: Form1 (and not my date form Field1).


How a man can suffer whilst making a form :D
 
S

S.Y.M. Wong-A-Ton

Change line 36 into:

XDocument.UI.SetSaveAsDialogLocation("C:\\temp\\");

Did you put the code in the "OnSaveRequest" event handler? It works fine
when I try it. When you add an "OnSaveRequest" to the form through
"Tools>Form Options>Open and Save>Save using custom code" the event handler
is added for you to the form, along with some comments. You need to add your
lines of code before the following comment:

// Write the code to be run before saving here.
 
K

Koen Alleman

Thanks to the help I've got from S.Y.M. Wong-A-Ton, I've managed to get this
form up and runing.

For people that have the same problem as I had, here's the code I've used
(in JScript):

function XDocument::OnSaveRequest(eventObj)
{
var nodeselname =
XDocument.DOM.selectSingleNode("/my:myFields/my:Field1").text
XDocument.UI.SetSaveAsDialogFileName(nodeselname);
XDocument.UI.SetSaveAsDialogLocation("C:\\temp\\");

eventObj.IsCancelled = eventObj.PerformSaveOperation();

XDocument.UI.Alert("Form saved");

eventObj.ReturnStatus = true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top