Default File Name using Field Name

D

Delnang

I have a field in my data source called FileName which is a concat of two
other fields. I want to use FileName as the default filename and have the
following Code in the Save code in the Form Options:

function XDocument::OnSaveRequest(eventObj)
{
var filePath = "file:///C:/";
var fileName =
XDocument.DOM.selectSingleNode("my:myFields/my:FileName").text;
XDocument.UI.SetSaveAsDialogFileName(fileName);
XDocument.UI.SetSaveAsDialogLocation(filePath);

eventObj.IsCancelled = eventObj.PerformSaveOperation();

if (eventObj.IsCancelled)
{
XDocument.UI.Alert("Save Cancelled");
}
else
{
XDocument.UI.Alert("Form saved");
}

eventObj.ReturnStatus = true;
}

I am using Jscript, InfoPath 2003 with SP2 - the error is:
The following error occurred:
Reference to undeclared namespace prefix: 'my'.
File:script.js
Line:4
Unspecified error

What am I doing wrong? Any suggestions?

Thanks,
Angie
 
G

Gavin McKay

Hello,

I can't advise on JavaScript, but in the .NET world that error means the xml
document does not understand the "my:" namespace. Either try it without
using the namespace:

"my:myFields/my:FileName"

or if that doesn't work you need to find a way to add the "my:" namespace so
that selectSingleNode understands what to do with it.

HTH

Gavin.
 
S

Shekar

Hi
Check in your script.js file has the following line of code:

XDocument.DOM.setProperty("SelectionNamespaces", "< Here the form name
space>");

if not you need to set the name space property.

Hope this helps you.
 

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