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

Tip: Looking for answers? Try searching our database.

Exchanging data between modules

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrea V.F. - 08 Jun 2005 10:15 GMT
Into an infopath form I need to call another module and pass to this
module an integer value. How could I do this (if this is possible)??

Thanks, Andrea.
Henning Krause [MVP - Exhange] - 08 Jun 2005 10:47 GMT
Hello,

what do you mean by "module"? Another InfoPath form?

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

> Into an infopath form I need to call another module and pass to this
> module an integer value. How could I do this (if this is possible)??
>
> Thanks, Andrea.
Andrea V.F. - 08 Jun 2005 11:44 GMT
I mean another "xsn" file.

For Example:
in file a.xsn there is a button. When i click this button it opens the
b.xsn file and I want to pass a value to b.
Henning Krause [MVP - Exhange] - 08 Jun 2005 12:04 GMT
Hello,

you can do this from within the script file (Note: This example is in C#,
but you can use JScript in a similar way).

// The url of the second form, must be absolute (i.e. c:\myforms\form.xsn).
This example opens a form that lies in the same directory as the source form
url = XDocument.Solution.URI;
url =
HttpUtility.UrlDecode(url.Substring(url.IndexOf("://")+4)).Replace("/",
"\\");
url = Path.Combine(Path.GetDirectoryName(url), "News Template.xsn");

// Open a new instance of the second xsn
doc = Application.XDocuments.NewFromSolution(url);

// Get the Datasource of the second form. Note: In Jscript you won't need
the casting to the IXMLDOMDocument2
dom = (IXMLDOMDocument2) doc.DOM;
// Set the namespace to the one used within the second document
dom.setProperty("SelectionNamespaces",
"xmlns:my=\http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-05T13:36:27\");

// Set the value
doc.DOM.selectSingleNode("//my:integervalue").text = 42;

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

>I mean another "xsn" file.
>
> For Example:
> in file a.xsn there is a button. When i click this button it opens the
> b.xsn file and I want to pass a value to b.
Andrea V.F. - 08 Jun 2005 12:45 GMT
I received an error in the code because I don't have HttpUtility in
JScript. So I assign to the variable "url" the path by hand
(url="C:\foo\module.xsn")

All works, but when I try to set the integer value I receive an error:
" doc.DOM.selectSingleNode(...) is null or is not an object". Using the
debug I've found that selectSingleNode returns "Null".

any suggestion?

Thanks for the help Henning.
Henning Krause [MVP - Exhange] - 08 Jun 2005 12:50 GMT
Hello,

as I said, the XPath must be valid, and the namespace must match the
namespace of the xsn you are opening.

If selectSingleNode is null, than no node that matches your XPath expression
was found. If all fails, take your debugger and look at the doc.DOM.xml
value. That contains the entire XML file, including the namespace
declarations.

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

>I received an error in the code because I don't have HttpUtility in
> JScript. So I assign to the variable "url" the path by hand
[quoted text clipped - 7 lines]
>
> Thanks for the help Henning.
Andrea V.F. - 08 Jun 2005 13:07 GMT
This is the doc.DOM.xml value:

<?xml version=\"1.0\"?><?mso-infoPathSolution
solutionVersion=\"1.0.0.2\" productVersion=\"11.0.6357\"
PIVersion=\"1.0.0.0\" href=\"file:///C:\jirapa\test.xsn\"
name=\"urn:schemas-microsoft-com:office:infopath:test:-myXSD-2005-06-08T09-49-50\"
?><?mso-application progid=\"InfoPath.Document\"?><my:campiPersonali
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-08T09:49:50\"
xmlns:xd=\"http://schemas.microsoft.com/office/infopath/2003\"
xml:lang=\"it\">
<my:Campo></my:Campo>
</my:campiPersonali>

I think the XPath is correct. I use:

doc.DOM.selectSingleNode("//my:Campo").text = 42;
Henning Krause [MVP - Exhange] - 08 Jun 2005 13:19 GMT
Hello,

have you registered the "my" namespace correctly?

In your case, try the following
// Set the namespace to the one used within the second document

doc.DOM.setProperty("SelectionNamespaces",
"xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-08T09:49:50\");
doc.DOM.selectSingleNode("//my:Campu");

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

> This is the doc.DOM.xml value:
>
[quoted text clipped - 13 lines]
>
> doc.DOM.selectSingleNode("//my:Campo").text = 42;
Andrea V.F. - 08 Jun 2005 14:21 GMT
Yes. I paste the whole of the OnClick event for the button:

function CTRL35_6::OnClick(eventObj)
{
    // Scrivere il codice qui
    debugger;
// The url of the second form, must be absolute (i.e.
c:\myforms\form.xsn).
//This example opens a form that lies in the same directory as the
source form
//url = XDocument.Solution.URI;
//url = url.Substring(url.IndexOf("://")+4).Replace("/", "\\");
//url = Path.Combine(Path.GetDirectoryName(url), "Test.xsn");
url="c:\\jirapa\\test.xsn"
// Open a new instance of the second xsn
doc = Application.XDocuments.NewFromSolution(url);

// Get the Datasource of the second form. Note: In Jscript you won't
need the casting to the IXMLDOMDocument2
dom = doc.DOM;
// Set the namespace to the one used within the second document
dom.setProperty("SelectionNamespaces",
"xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-05T13:36:27\"");

// Set the value
doc.DOM.selectSingleNode("//my:Campo").text = 42;

}
Henning Krause [MVP - Exhange] - 09 Jun 2005 08:37 GMT
Hello,

you must use your namespace... not mine :-)

your code should work when you use this:

dom.setProperty("SelectionNamespaces",
"xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-06-08T09:49:50\"");

doc.DOM.selectSingleNode("//my:Campo").text = "42";

Greetings,
Henning Krause [MVP - Exchange]
==========================
Visit my website: http://www.infinitec.de
Try my free Exchange Explorer: Mistaya
(http://www.infinitec.de/software/mistaya.aspx)

> Yes. I paste the whole of the OnClick event for the button:
>
[quoted text clipped - 24 lines]
>
> }
Andrea V.F. - 09 Jun 2005 10:18 GMT
It Works :) Thanks Thanks and again Thanks.

You Solved Me a Lot of Problems.

Andrea.
 
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.