Transferring data between two forms - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Transferring data between two forms

Last post 09-19-2011 02:16 PM by gdgonzal. 23 replies.
Page 2 of 2 (24 items) < Previous 1 2
Sort Posts: Previous Next
  • 08-19-2009 02:18 PM In reply to

    Re: Transferring data between two forms

    Hi Daniel-  Are experimenting with the "var" lines of code, I got it to work!!!!!!!!!!!!!!!! The correct path names are:

    var form1Field = XDocument.DOM.selectSingleNode("/dfs:myFields/my:SetUserName");

    var form2Field = objNewForm.DOM.selectSingleNode("/dfs:myFields/my:SetName");

    I needed to use "dfs" and drop the "/dataFields/"  in the path name.

    Thank you very much again for your help Daniel!!





  • 08-31-2009 04:34 PM In reply to

    • Daniels
    • Not Ranked
    • Joined on 07-28-2009
    • Melbourne, Australia
    • Posts 18

    Re: Transferring data between two forms

    See article Programattically Transfer Data Between InfoPath Forms for details and instructions on how to transfer data between two InfoPath forms programmatically using a JScript example similar to the above.

    If using SharePoint you can submit the data to a SharePoint list from the first form eith using a CAML query and the SharePoint lists web service or the forms main submit data source, then load the data into the second form from the SharePoint list using a secondary data connection.  If not using SharePoint, this can also be achieved by submitted to an external database (Access) or even an xml file (default) which can then be used as a secondary datasource in the second form to retrieve the data. 

    SharePoint Admin & Dev - SharePoint and InfoPath Development

    Web Development & Programming - Php, C#, .NET Framework, SEO Tips - Free SEO, Webmaster Resources
  • 09-01-2009 11:26 AM In reply to

    Re: Transferring data between two forms

    Thank you again Daniel. Great info!

  • 03-02-2010 05:29 AM In reply to

    Re: Transferring data between two forms

    I have been following your example and trying to rewrite the same code in C#

    here is my code

    1. string strNewFormPath = @http://pathToForm;

    2. MSXML2.IXMLDOMDocument3 objNewForm = new MSXML2.DOMDocument50Class();

    3. objNewForm.load(strNewFormPath);

    4. objNewForm.setProperty("SelectionNamespaces", "xmlns:xsi='' xmlns:my='' xmlns:xd=''");

    5. MSXML2.IXMLDOMDocument3 objExternalData = new MSXML2.DOMDocument50Class();

    6. objExternalData.validateOnParse=false;

    7. objExternalData.loadXML(objNewForm.xml);

    8. objExternalData.setProperty("SelectionNamespaces", "xmlns:xsi='' xmlns:my='' xmlns:xd='' xmlns:dfs='' xmlns:ns1='' xmlns:soap=''");

    9. objNewForm.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text = objExternalData.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text;

    10. objNewForm.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text = objExternalData.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text;

    It is all good through step number 8. On step 9 it has a problem with namespace for right side of the assignment, where it claims that namespace for this object is null.

    objNewForm.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text = objExternalData.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text;

    I though I assigned a namespace for this object at step 8?

    Any help is more than great.

    Thank you in advance.

  • 03-02-2010 05:58 AM In reply to

    Re: Transferring data between two forms

     What's the exact error that you're getting?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-02-2010 06:15 AM In reply to

    Re: Transferring data between two forms

    Following error is displayed when I run source form, or the form from which I want to send/copy fields into the second form 

    Object reference not set to an instance of an object.
       at _c_Intelligence_Analysis.FormCode.CTRL120_5_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)


    when I run debug and look into watch of all objects, and get to number 9 from the above code

    9. objNewForm.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text = objExternalData.selectSingleNode("/my:myFields/my:group3/my:group4/my:txtMonthlySummary").text;

    it says that for this object


    it states

    Reference to undeclared namespace prefix: 'my'

     Thank you for your time

  • 03-02-2010 06:38 AM In reply to

    Re: Transferring data between two forms

     That certainly is puzzling.  Would you mind putting up an example of one of these XML files on here so someone could look at it?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-02-2010 07:10 AM In reply to

    Re: Transferring data between two forms

    I hope this is what you are talking about. I just took out  href="file:///C:"  and <my:txtHyperLink>http://</my:txtHyperLink>

    xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="" productVersion="12.0.0" PIVersion="" href="file:///C:" name="urn:schemas-microsoft-com:office:infopath:SIPA-1a:-myXSD-2010-01-11T12-50-42" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><?mso-infoPath-file-attachment-present?><my:myFields xmlns:xsi="" xmlns:xhtml="" xmlns:dfs="" xmlns:tns="" xmlns:s1="" xmlns:my="" xmlns:xd="" xml:lang="en-us">





    <my:attachmentBox xsi:nil="true"></my:attachmentBox>




    <my:field2 xsi:nil="true"></my:field2>

    <my:txtAtt xsi:nil="true"></my:txtAtt>



    <my:ddlUpdateType>Update Report</my:ddlUpdateType>

    <my:ddlMonthOfMonthlyUpdate>January 2010</my:ddlMonthOfMonthlyUpdate>


    <my:txtTextBoxMonthlyUpdateTitle>January 2010</my:txtTextBoxMonthlyUpdateTitle>







  • 09-19-2011 02:16 PM In reply to

    Re: Transferring data between two forms

    Hello Daniels,

     I am experiencing the same issues defining dfs because of ambiguous xpath.  I am also using Access 2003 as my main data source and when I look at the data field Details all I see is "Key_Field (Optional attribute field)" which is the unique indentifier field I am trying to pass from form 1 to form 2 when it's opened.  There is no Namespace defined for this field that I can see.   The only time I see a Namespace being defined is within myFields, not either queryFields or dataFields I am pulling from Access 2003.

    I believe this is also addressed within this article when you suggest using a var to define this...the problem is you don't seem to mention where exactly in the code this should be defined.

    Can anyone advise on how I should implement this within the code example you've provided?

    var  form1Field = XDocument.DOM.selectSingleNode("/my:myFields/my:dataFields/my:SetUserName");

    var  form2Field = objNewForm.DOM.selectSingleNode("/my:myFields/my:dataFields/my:SetName");

    Then set the value of the form2 field using the following:

    form2Field.text = form1Field.text;


Page 2 of 2 (24 items) < Previous 1 2
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.