Passing a parameter to InfoPath

H

Helen Trim

I am new to InfoPath developing, so I hope that someone can help. I have an
InfoPath 2007 form that recieves data from a web service for a given patient.
I have a web application ( C#, Visual Studio 2005 ) that opens the InfoPath
form and I want to pass it the patient number. My code looks like this so
far:



Microsoft.Office.Interop.InfoPath.Application IP;
Uri FormPathUri; // URI of the blank InfoPath form
XDocument Document; // The form to open in InfoPath

IP = new Microsoft.Office.Interop.InfoPath.Application();
Document = IP.XDocuments.NewFromSolution(FormPathUri.AbsoluteUri);

// I need a line here
Document.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/tns:DatabaseToXMLFile/tns:pat_no").text = Pat_No;



I need a line of code to specify the namespaces used in the selectSingleNode
line. What should it be? I have tried lots of things without success, so I
will be very grateful for your advice.



Thanks,

Helen
 
S

S.Y.M. Wong-A-Ton

To answer your question about specifying namespaces, you can try the following:

Document.DOM.setProperty("SelectionNamespaces", "xmlns:dfs='http://...'
xmlns:tns='http://...'");

Put a space between the individual namespace declarations. You can save a
filled-out form locally as an XML file, open it up in Notepad, and then
lookup the namespace values for "dfs" and "tns" in the XML for the form.
 
S

S.Y.M. Wong-A-Ton

Addendum: You can also extract the form files, open up the XSD file(s) that
are stored in the XSN, and lookup the namespaces that way.
 
H

Helen Trim

Thank you for replying.

I have tried this already as I found it in the documentation, but it doesn't
work in my code. I get an error saying that Document.DOM does not have a
setProperty method.

Any other ideas?

Thanks,
Helen
 
S

S.Y.M. Wong-A-Ton

It's best to list everything you've tried. That way you will avoid people
telling you to try things you've already tried, which in turn will help you
find an appropriate solution quicker; just a tip for the next time. :) The
only other thing I can suggest for now is to ignore namespaces in your XPath
expression by using the local-name() function in your XPath expressions.
 

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