InfoPath: Opening Another InfoPath Form (w/ Parameter)

J

John.Tucker

Tried my usual method of getting an answer to this (Google) and did not find
a satisfactory one; thought would be simple...

Have one InfoPath form and would like to open another InfoPath form (BUT
WOULD LIKE TO PASS A QUERY PARAMETER to the target form, i.e., don't want a
blank form but a form with specific data to come up).

Is there a relatively easy way of doing this?

John
 
M

Michelle

Are you opening the second infopath form from within the first
infopath form?
Are you using Javascript or managed code (like C#)?

If you are opening the second form from within the first and are using
C# then you could try the following:
// The following function handler is created by Microsoft Office
InfoPath. Do not
// modify the type or number of arguments.
[InfoPathEventHandler(MatchPath="btnCopy",
EventType=InfoPathEventType.OnClick)]
public void btnCopy_OnClick(DocActionEvent e)
{
// copy current document's XML
IXMLDOMDocument newDoc = thisXDocument.DOM;

// manipulate the data in the copy
newDoc.documentElement.selectSingleNode("/my:myFields/my:field1").text
= "test";
newDoc.documentElement.selectSingleNode("/my:myFields/my:field2").text
= "1";
newDoc.documentElement.selectSingleNode("/my:myFields/my:field3").text
= "test2";

// get the path of the template
string strTemplatePath = getTemplatePath();

// call NewSolutionWithData to open a new Form and load the XML
thisApplication.XDocuments.NewFromSolutionWithData(newDoc.documentElement,
strTemplatePath, (int)XdDocumentVersionMode.xdFailOnVersionOlder);
thisApplication.XDocuments.Close(0);
}

What this does is on the onclick event of a button on the form,
creates a copy of the XML in the document, then manipulates the data
in the copied XML (effectively passing the parameter), then creates a
new instance of InfoPath with the modified (populated) XML.

You could then in your onload event of the form have it use the value
of the node you populated to query a data source to populate other
fields, for example if you passed in an Order ID or such.

Hope this helps.
Michelle Beall
 
J

josephjc

Is there a way to do this in javascript please?
I cannot use managed code because Infopath toolkit is only available
for VS 2003 and I have 2005.
10x
 
B

Ben Walters

Hey Joseph,
The InfoPath toolkit is available for VS2005 however it is included as part
of Visual Studio Tools for Office (VSTO), if you have an MSDN subscription
you should be able to download it from there.

Cheers
Ben
 
L

Lance M

Hi Joseph,

If you manage to get the toolkit, I have a question for you: are you
going to be doing anything with the form that you are openeing? It
sounds to me like you are just accessing it to look at it's data. If so
there is another way using the DOM and data connections. You could then
select a single node based on whatever the query string criterion are,
and load it into an xmlnode or something similar to look at the data.
If you are modifying the data, chances are you do need to open the form
:p.

Lance M.
 
J

josephjc

10x Ben, but I did not manage to get the toolkit. What I really need is
to connect forms together. I am creating a Claims Management System and
want to connect claims form with customer forms. I would like that when
a user submits a claim form a customer form is automatically loaded
with the claim number present.

10x again,
Joseph
 
Top