I'm trying to change the value of a field using the selectSingleNode method. I have a test form that I use to test and debug new code before I use it on my production form. In the Test form, I used the following code to change the value of the "Test" field to "123":
XDocument.DOM.selectSingleNode("my:myFields/my:Test").text = "123";
This worked fine, but when I moved into my production form, I got the following error:
Reference to undeclared namespace prefix: 'my'.
I looked back through my code and I realized tha the namespace definition that was in my test form was not in my production form, so I added the following line of code at the top of the Script.js:
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-01-22T18:18:32" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
The next time I ran the code, I got the following error:
'XDocument.DOM.selectSingleNode(...)' is null or not an object
I don't know what to do at this point. Any ideas?