Auto Create filename when saving?

C

Chip Gandy

I'm looking at creating an infopath form solution for a number of tasks that
currently use word docs. I'd like to be able to somehow automate the
creation of the filename for when the user saves it. I don't want to end up
with 500 docs named form1-form500. Something that will make it unique when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
H

Henning Krause [MVP - Exhange]

Hello,

under Tools --> Form options --> Open and Save, check the "Save using custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)
 
C

Chip Gandy

Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not sure
where to put this and what would need to be put in there. From what I'm
finding though, it looks like i'll ahve to do some custom coding to get it to
use existing information in the document to automatically come up with a file
name? Do you know of any good sources for examples that i can use to figure
out what to create?

Thank you!

Henning Krause said:
Hello,

under Tools --> Form options --> Open and Save, check the "Save using custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
I'm looking at creating an infopath form solution for a number of tasks
that
currently use word docs. I'd like to be able to somehow automate the
creation of the filename for when the user saves it. I don't want to end
up
with 500 docs named form1-form500. Something that will make it unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
H

Henning Krause [MVP - Exhange]

Hello,

to get this to work you must have InfoPath Service Pack 1 up and running,
otherwise the required functionality is not there. If you follow the
instructions in my last post, and then click "Edit", you will end up in the
script editor. And InfoPath has created a script block like this:

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
//=======
function XDocument::OnSaveRequest(eventObj) {
// Write the code to be run before saving here.

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.
eventObj.ReturnStatus = true;
}

So, if you insert the line
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

before the eventObj.IsCancelled line, you will end up with the Save-As
dialog poping up suggesting "customname.xml" as the filename.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not sure
where to put this and what would need to be put in there. From what I'm
finding though, it looks like i'll ahve to do some custom coding to get it
to
use existing information in the document to automatically come up with a
file
name? Do you know of any good sources for examples that i can use to
figure
out what to create?

Thank you!

Henning Krause said:
Hello,

under Tools --> Form options --> Open and Save, check the "Save using
custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
I'm looking at creating an infopath form solution for a number of tasks
that
currently use word docs. I'd like to be able to somehow automate the
creation of the filename for when the user saves it. I don't want to
end
up
with 500 docs named form1-form500. Something that will make it unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
C

Chip Gandy

ah ha! got it this time. i wasn't sure where to put it. woohoo! Thank you!

now to find more info on getting it to create a name based on information in
the document. I saw a post somewhere about it but it was way more than i
needed. I just want to create the name based on 3 fields so it's unique.

Thanks

Henning Krause said:
Hello,

to get this to work you must have InfoPath Service Pack 1 up and running,
otherwise the required functionality is not there. If you follow the
instructions in my last post, and then click "Edit", you will end up in the
script editor. And InfoPath has created a script block like this:

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
//=======
function XDocument::OnSaveRequest(eventObj) {
// Write the code to be run before saving here.

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.
eventObj.ReturnStatus = true;
}

So, if you insert the line
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

before the eventObj.IsCancelled line, you will end up with the Save-As
dialog poping up suggesting "customname.xml" as the filename.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not sure
where to put this and what would need to be put in there. From what I'm
finding though, it looks like i'll ahve to do some custom coding to get it
to
use existing information in the document to automatically come up with a
file
name? Do you know of any good sources for examples that i can use to
figure
out what to create?

Thank you!

Henning Krause said:
Hello,

under Tools --> Form options --> Open and Save, check the "Save using
custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


I'm looking at creating an infopath form solution for a number of tasks
that
currently use word docs. I'd like to be able to somehow automate the
creation of the filename for when the user saves it. I don't want to
end
up
with 500 docs named form1-form500. Something that will make it unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
H

Henning Krause [MVP - Exhange]

Well, that shouldn't be so hard, since you can access the fields via
XDocument.DOM.selectSingleNode("<put xpath expression here").text;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
ah ha! got it this time. i wasn't sure where to put it. woohoo! Thank
you!

now to find more info on getting it to create a name based on information
in
the document. I saw a post somewhere about it but it was way more than i
needed. I just want to create the name based on 3 fields so it's unique.

Thanks

Henning Krause said:
Hello,

to get this to work you must have InfoPath Service Pack 1 up and running,
otherwise the required functionality is not there. If you follow the
instructions in my last post, and then click "Edit", you will end up in
the
script editor. And InfoPath has created a script block like this:

//=======
// The following function handler is created by Microsoft Office
InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
//=======
function XDocument::OnSaveRequest(eventObj) {
// Write the code to be run before saving here.

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.
eventObj.ReturnStatus = true;
}

So, if you insert the line
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

before the eventObj.IsCancelled line, you will end up with the Save-As
dialog poping up suggesting "customname.xml" as the filename.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not
sure
where to put this and what would need to be put in there. From what
I'm
finding though, it looks like i'll ahve to do some custom coding to get
it
to
use existing information in the document to automatically come up with
a
file
name? Do you know of any good sources for examples that i can use to
figure
out what to create?

Thank you!

:

Hello,

under Tools --> Form options --> Open and Save, check the "Save using
custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


I'm looking at creating an infopath form solution for a number of
tasks
that
currently use word docs. I'd like to be able to somehow automate
the
creation of the filename for when the user saves it. I don't want
to
end
up
with 500 docs named form1-form500. Something that will make it
unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
S

Sven Olav

Hai,

I'm trying to figure out how to implementate your advice, but it will not
work for so far. For now my code is as shown below:

function XDocument::OnSaveRequest(eventObj)
{
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

eventObj.IsCancelled = eventObj.PerformSaveOperation();

eventObj.ReturnStatus = true;
}

Now, i want to generate the filename from the textfield "field1" instead of
"customname.xml". Could you please show me how to import your advice and how
the code finally will look?

Many thanks,


Henning Krause said:
Well, that shouldn't be so hard, since you can access the fields via
XDocument.DOM.selectSingleNode("<put xpath expression here").text;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
ah ha! got it this time. i wasn't sure where to put it. woohoo! Thank
you!

now to find more info on getting it to create a name based on information
in
the document. I saw a post somewhere about it but it was way more than i
needed. I just want to create the name based on 3 fields so it's unique.

Thanks

Henning Krause said:
Hello,

to get this to work you must have InfoPath Service Pack 1 up and running,
otherwise the required functionality is not there. If you follow the
instructions in my last post, and then click "Edit", you will end up in
the
script editor. And InfoPath has created a script block like this:

//=======
// The following function handler is created by Microsoft Office
InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
//=======
function XDocument::OnSaveRequest(eventObj) {
// Write the code to be run before saving here.

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.
eventObj.ReturnStatus = true;
}

So, if you insert the line
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

before the eventObj.IsCancelled line, you will end up with the Save-As
dialog poping up suggesting "customname.xml" as the filename.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not
sure
where to put this and what would need to be put in there. From what
I'm
finding though, it looks like i'll ahve to do some custom coding to get
it
to
use existing information in the document to automatically come up with
a
file
name? Do you know of any good sources for examples that i can use to
figure
out what to create?

Thank you!

:

Hello,

under Tools --> Form options --> Open and Save, check the "Save using
custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


I'm looking at creating an infopath form solution for a number of
tasks
that
currently use word docs. I'd like to be able to somehow automate
the
creation of the filename for when the user saves it. I don't want
to
end
up
with 500 docs named form1-form500. Something that will make it
unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 
A

Anders

Hi,

I found this example. Maybe it can help.

http://msdn.microsoft.com/library/d...p2003_ta/html/odc_InfoPath_extending_save.asp

/Anders


Sven Olav said:
Hai,

I'm trying to figure out how to implementate your advice, but it will not
work for so far. For now my code is as shown below:

function XDocument::OnSaveRequest(eventObj)
{
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

eventObj.IsCancelled = eventObj.PerformSaveOperation();

eventObj.ReturnStatus = true;
}

Now, i want to generate the filename from the textfield "field1" instead of
"customname.xml". Could you please show me how to import your advice and how
the code finally will look?

Many thanks,


Henning Krause said:
Well, that shouldn't be so hard, since you can access the fields via
XDocument.DOM.selectSingleNode("<put xpath expression here").text;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Chip Gandy said:
ah ha! got it this time. i wasn't sure where to put it. woohoo! Thank
you!

now to find more info on getting it to create a name based on information
in
the document. I saw a post somewhere about it but it was way more than i
needed. I just want to create the name based on 3 fields so it's unique.

Thanks

:

Hello,

to get this to work you must have InfoPath Service Pack 1 up and running,
otherwise the required functionality is not there. If you follow the
instructions in my last post, and then click "Edit", you will end up in
the
script editor. And InfoPath has created a script block like this:

//=======
// The following function handler is created by Microsoft Office
InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
//=======
function XDocument::OnSaveRequest(eventObj) {
// Write the code to be run before saving here.

eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.
eventObj.ReturnStatus = true;
}

So, if you insert the line
XDocument.UI.SetSaveAsDialogFileName("customname.xml");

before the eventObj.IsCancelled line, you will end up with the Save-As
dialog poping up suggesting "customname.xml" as the filename.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


Thanks... I think. :) I'm going to play dumb here because I'm not
following. I see in the script editor where there's code but I'm not
sure
where to put this and what would need to be put in there. From what
I'm
finding though, it looks like i'll ahve to do some custom coding to get
it
to
use existing information in the document to automatically come up with
a
file
name? Do you know of any good sources for examples that i can use to
figure
out what to create?

Thank you!

:

Hello,

under Tools --> Form options --> Open and Save, check the "Save using
custom
code" box.

In the OnSave event, use the following code:
XDocument.UI.SetSaveAsDialogFileName("customname.xml");
e.IsCancelled = e.PerformSaveOperation();
// Write the code to be run after saving here.
e.ReturnStatus = true;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)


I'm looking at creating an infopath form solution for a number of
tasks
that
currently use word docs. I'd like to be able to somehow automate
the
creation of the filename for when the user saves it. I don't want
to
end
up
with 500 docs named form1-form500. Something that will make it
unique
when
saved and the user won't have to give it a different name.

Is this possible?

Thanks
 

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