Saving an infopath form

J

jy

Hello, i am new with infopath
i would to automatically name a form with a specific name and date when i
click on the save button

the following are the code that i have tried to use. but i click on save it
display's the following
Request for Business Cards for null null
in the save window

function XDocument::OnSaveRequest(eventObj)
{

//Declarations using fields within the form. note the tree structure for the
fields used.
var Name = XDocument.DOM.selectSingleNode("my:LastName").text;
var Today1 = XDocument.DOM.selectSingleNode("/my:Date");

// Write the code to be run before saving here.
XDocument.UI.SetSaveAsDialogFileName("Request for Business Cards for " +
Name + " " + Today1);

// have the actual save function occur and return back to the current form.
eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.

eventObj.ReturnStatus = true;

hope someone can help me thank you
 
S

S.Y.M. Wong-A-Ton

The XPath expressions to the last name and date fields are probably
incorrect. It can be a challenge to find the right expression, but try
"//my:LastName" instead of "my:LastName" and "//my:Date" instead of
"/my:Date". I'm just guessing, since I do not know what the structure of the
main data source of your form looks like.
 
J

jy

here is part of the main data source as the main data source is faily long.

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution
solutionVersion="1.0.0.626" productVersion="11.0.6565" PIVersion="1.0.0.0"
href="file:///C:\01%20-%20Jean-Yves%20Documents\infopath\Business%20Cards%20Request\Business%20Cards%20Request%20View%20-2%20(rev%202007%2008).xsn"
name="urn:schemas-microsoft-com:eek:ffice:infopath:Business-Cards-Request-View--2--rev-2007-08-:-myXSD-2007-05-23T20-36-00"
?><?mso-application progid="InfoPath.Document"?><my:RequestForBusinessCards
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:eek:="urn:schemas-microsoft-com:eek:ffice:eek:ffice"
xmlns:ss="urn:schemas-microsoft-com:eek:ffice:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-05-23T20:36:00"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-ca">
<my:BusinessCards>
<my:Date>2007-09-15</my:Date>
<my:ContactInformation>
<my:FirstName></my:FirstName>
<my:LastLame></my:LastLame>
<my:Department></my:Department>
<my:TelNumber>(000) 000-0000</my:TelNumber>
<my:Extension></my:Extension>
<my:Address>
the scipt to the OnSaveRequest is as follow

//=======
// 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)
{

//Declarations using fields within the form. note the tree structure for the
fields used.
// var Name =
XDocument.DOM.selectSingleNode("my:RequestForBusinessCards/my:ContactInformation/my:LastName").text;
var Today1 =
XDocument.DOM.selectSingleNode("my:RequestForBusinessCards/my:BusinessCards/my:Date").text;

// (my:RequestForBusinessCards/my:BusinessCards/my:Date)

// Write the code to be run before saving here.
XDocument.UI.SetSaveAsDialogFileName("Request for Business Cards for " +
Today1);

// have the actual save function occur and return back to the current form.
eventObj.IsCancelled = eventObj.PerformSaveOperation();

// Write the code to be run after saving here.

eventObj.ReturnStatus = true;
}
 
S

S.Y.M. Wong-A-Ton

The XPath expression that you have right now for my:Date should work. Change
the one for my:LastName to

"my:RequestForBusinessCards/my:BusinessCards/my:ContactInformation/my:LastName"

You are currently missing my:BusinessCards in the XPath expression for
my:LastName.

By the way, is my:BusinessCards a repeating node? If it is, you will have to
use something like

"my:RequestForBusinessCards/my:BusinessCards[1]/my:ContactInformation/my:LastName"

to get the first one in the group, [2] to get the second one, etc.
 

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