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 2008

Tip: Looking for answers? Try searching our database.

the timestamp matters with SelectionNamespace xmlns:my ???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
waffle93 - 03 Mar 2008 19:31 GMT
I created a form and added some VBScript code to it.  After having
difficulties with the code I deleted all of it.  Now I am adding code back to
the form but cannot reference any of the fields in it, apparently because it
does not recognize the namespace declaration.

The error I receive is:

>>>  A run-time error has occurred...
>>>  Object required:  'XDocument.DOM.selectSingleNode(...)'

After troubleshooting I figured out that you can't just copy in a substitute
for the namespace declaration that InfoPath automatically puts in your script
the first time you write to it.  I tested this by creating a new, blank form
and added one field and one button.  If I use the auto-generated namespace
declaration then clicking the button will display the value of the text box.  
If I copy over the namespace declaration (with a different timestamp) then I
get the same error as above.  

The code is as simple as this:

---------------------------------
'<namespacesDefinition>
XDocument.DOM.setProperty "SelectionNamespaces",
"xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-03-03T19:04:56"""
'</namespacesDefinition>

Sub CTRL2_5_OnClick(eventObj)
    myText = XDocument.DOM.selectSingleNode("/my:myFields/my:dummyField").Text
    msgbox myText
End Sub
---------------------------------

...so what is going on here?  If the timestamp in the namespace declaration
is sensitive to each form then how do I re-create this for my form?

Also...curious...does the form query schemas.microsoft.com every time it
opens to translate the namespace?
Greg Collins - 04 Mar 2008 17:43 GMT
No, the form does not query the URL in the namespace definition. The
definition can be anything. URLs are often used because that URL offers more
information on the schema.

The namespace definition must match exactly. "XYZ" does not match "ABC", nor
does "2008-03-03T19:03:56" match "2008-03-01T05:23:54" The entire string, as
a whole, within the quotes constitutes the definition of that namespace. If
you substitute in another one then you have a different namespace. This is
no different than human names. My name is Greg Collins. There are other
people named Greg Collins in this world. So when you use the name Greg
Collins -- who are you referring to? When you use the namespace "my", what
are you referring to? The definition helps to keep all that straight.

If you have lost the definition, extract your form files and get a copy of
it from the manifest.xsf, template.xml, view1.xml, or myschema.xsd.

Signature

Greg Collins
Microsoft MVP
Visit Braintrove at http://www.braintrove.com
Visit InfoPathDev at http://www.infopathdev.com

waffle93 - 04 Mar 2008 19:12 GMT
Thank you Greg.  I also noticed that if I click on any of the fields from my
Data Source and then click on the tab 'Advanced' that there is a namespace
definition there.  I copied that to my code and it works.

Thanks for the explanation, that makes sense.  As a footnote it appears the
namespace definition is created using the date/time the form was created.

-ken

> No, the form does not query the URL in the namespace definition. The
> definition can be anything. URLs are often used because that URL offers more
[quoted text clipped - 11 lines]
> If you have lost the definition, extract your form files and get a copy of
> it from the manifest.xsf, template.xml, view1.xml, or myschema.xsd.
Greg Collins - 04 Mar 2008 22:50 GMT
That is correct. The date/time of the form creation is indeed used in the
namespace definition. It's a means to help ensure (as much as possible) that
the definition is unique, while still being more useful than a GUID.

Signature

Greg Collins
Microsoft MVP
Visit Braintrove at http://www.braintrove.com
Visit InfoPathDev at http://www.infopathdev.com


Rate this thread:






 
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.