Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2006

Tip: Looking for answers? Try searching our database.

SaveAs function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Koen Alleman - 29 Mar 2006 15:32 GMT
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.Y.M. Wong-A-Ton - 30 Mar 2006 07:56 GMT
Try removing the double quotes around "nodeselname.text" like this

XDocument.UI.SetSaveAsDialogFileName(nodeselname.text);

and try it again.
---
S.Y.M. Wong-A-Ton

> 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'.
[quoted text clipped - 8 lines]
> But this doesn't work. What I'm I doing wrong?
> Can anyone give me the code (JScript)?
Koen Alleman - 30 Mar 2006 08:38 GMT
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

> Try removing the double quotes around "nodeselname.text" like this
>
[quoted text clipped - 16 lines]
> > But this doesn't work. What I'm I doing wrong?
> > Can anyone give me the code (JScript)?
S.Y.M. Wong-A-Ton - 30 Mar 2006 11:24 GMT
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.

---
S.Y.M. Wong-A-Ton

> No, this doesn't work.
> I get an error message saying something is wrong in my script (on line 36).
[quoted text clipped - 29 lines]
> > > But this doesn't work. What I'm I doing wrong?
> > > Can anyone give me the code (JScript)?
Koen Alleman - 30 Mar 2006 12:04 GMT
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;
}

> 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'.
[quoted text clipped - 8 lines]
> But this doesn't work. What I'm I doing wrong?
> Can anyone give me the code (JScript)?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.