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 / November 2005

Tip: Looking for answers? Try searching our database.

JScript Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mullie21 - 15 Nov 2005 00:38 GMT
I'm having issues assigning a value from JScript to a field. This is the
frist time I've coded in JScript.  I read earlier that I had to declare my
namespaces.  First question, how do I determine my namespaces?  I believe I
only have 'My' because I haven't created any others.  I used this to set the
namespace

XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-11-02T18:03:47"');

The field I'm trying to put data into is not linked to a database, its just
a field in the form.  I'm using the following statement:

function XDocument::OnSaveRequest(eventObj)
{    // Write the code to be run before saving here.

    eventObj.IsCancelled = eventObj.PerformSaveOperation();

    XDocument.DOM.selectSingleNode("//myFields/my:Saved").text = true;

    eventObj.ReturnStatus = true;}

As you can tell, I'm trying to populate a value, when the user saves the
form.  I've tried this a million different ways, and everytime I get the same
error, "'XDocument.DOM.selectSingleNode(...)' is null or not an object".

What am I doing wrong?  Any help is appreciated.

Thanks,

Chris
Franck Dauché - 15 Nov 2005 00:53 GMT
Hi Chris,

You don't need to declare anything.
Instead try:
XDocument.DOM.selectSingleNode("/my:myFields/my:Saved").text = true;
Note the initial "/my:"

Hope that it helps.

Regards,

Franck Dauché

> I'm having issues assigning a value from JScript to a field. This is the
> frist time I've coded in JScript.  I read earlier that I had to declare my
[quoted text clipped - 26 lines]
>
> Chris
Mullie21 - 15 Nov 2005 03:01 GMT
Frank,

Thanks for your help, but that still did not work.  I'm still getting that
same error message.  Any other ideas?

Thanks again,

Chris

> Hi Chris,
>
[quoted text clipped - 39 lines]
> >
> > Chris
Mullie21 - 15 Nov 2005 03:02 GMT
Also, if I don't declare the namespace, then I get an undeclared namespace
error:  "Reference to undeclared namespace prefix: 'my'".

Thanks,

Chris

> Hi Chris,
>
[quoted text clipped - 39 lines]
> >
> > Chris
Franck Dauché - 15 Nov 2005 03:28 GMT
Hi Chris,

Just to make sure that we are on the same page, create a new blank form.  
Drop one textbox on the form.  Your schema should be: myFields/field1.
Drop one button, and go to the MSE (right-click on the button / Button
Properties /  Edit Form Code) and put the following line of code in the
OnClick event:
XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = "test";

run and click the button.  Does it work?

Note: you don't have to write any setProperty (it is done by IP
automatically).

Regards,

Franck Dauché

> Also, if I don't declare the namespace, then I get an undeclared namespace
> error:  "Reference to undeclared namespace prefix: 'my'".
[quoted text clipped - 46 lines]
> > >
> > > Chris
Mullie21 - 15 Nov 2005 03:53 GMT
Frank,

I actually just got it.  Instead of using a stored value to determine
whether or not a user had saved the form, I'm going to use the IsNew
function.  I've got it working perfectly.

Thanks for your help.  This really is a great discussion board.

Chris

> Hi Chris,
>
[quoted text clipped - 64 lines]
> > > >
> > > > Chris
 
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.