Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS - InfoPath Dev
in

InfoPath Dev

Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

Last post 07-15-2009 08:23 AM by kennebg. 38 replies.
Page 1 of 3 (39 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 07-09-2009 11:47 AM

    Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Hello, I'm working with the trial version of DBXL and I can see it will allow me to do what I need but having a problem completing my test with it.I can bind a repeating table directly to the DBXL secondary connection and it will display the data perfectly.  What I really need to do though it to copy/clone data from the DBXL connection to a repeating table in the main data source.  I have found a number of examples on copying secondary data and I cannot seem to be able to get it to work.  I defines the NameSpace for it,(which may be wrong but no errors at this point) but I get nothing back when I try to access the secondary from my JS.  I'm thinking there could be difference between referencing the DBXL created data source and just a standard Sharepoint list data source. DBXL is getting it's data from SharePointQuery using the GetListItemsStr method. Since it will populate a bound repeating table I can see that it is working properly. But is JS when I try to get the value and copy it to the main Repeating Table I get nothing. No errors, no nothing.I am still pretty new to JS on Infopath and less than three days new to DBXL.I have to use Infopath 2003 at this point as it is deployed globally with my firm.  The server is Windows 2003 with Sharepoint MOSS 2007 Standard.Here is the code which I got from InfopathDev and modified to try and do what I want but it is still not working. I have some things commented out that I have tried also but I left them in in case they help?

    ***************************************************************************************************************************************************

    Get a copy of the main DOM node.
         var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").cloneNode(true);
         // Clear the main DOM nodes.
         XDocument.DOM.selectNodes("/my:myFields/my:group3/my:Test_Details").removeAll();
         // Copy nodes from 2DS to main DOM.
         var nodes = XDocument.GetDOM("GetListItemsStr").selectNodes("/ns1:myFields/ns1:dataFields/ns1:GetListItemsStr");
         XDocument.UI.Alert(nodes.text);
         var node;
         while(node = nodes.nextNode())
         {
              clone.selectSingleNode("/my:HuInput").text = node.selectSingleNode("Test_Serial_Number").text;
              XDocument.UI.Alert(node.text);
              XDocument.View.ExecuteAction("xCollection::insert", "group4_7");
              //XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").appendChild(clone.cloneNode(true));
         }

     *********************************************************************************************************************************************************

    I have two different Namespace definitions I have tried and while they do not produce errors neither works:

    ********************************************************

    //XDocument.GetDOM( "GetListItemsStr" ).setProperty( "SelectionNamespaces" , 'xmlns:ns1="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

    XDocument.GetDOM( "GetListItemsStr" ).setProperty( "SelectionNamespaces" , 'xmlns:ns1="http://qdabra.com/databaseservice"');

    **************************************************************************************************

    I was going to post a pic of the DBXL secondary data source from InfoPath but I can't figure out how to do it on this forum.

    Any help would be greatly appreciated.

     Thanks everyone!!!!!

     

  • 07-09-2009 12:02 PM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Hi --

    If you save your form as source files you'll be able to get the namespace definitions from the sampledata.xml file. Open it up with a text editor search for xmlns:ns1 or look for the data connection GetListItemsStr. On the form I'm currently working on, ns1 = http://qdabra.com/webservices/ but it would be best to check your sampledata.xml.

    Hilary Stoupa

  • 07-09-2009 12:30 PM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Here's what I found in Sampledata.xml:

    <xd:DataConnection Name="GetListItemsStr">
      <dfs:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-04-28T14:41:50" xmlns:ns1="http://qdabra.com/databaseservice" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
       <dfs:queryFields>
        <ns1:GetListItemsStr>
         <ns1:listUrl/>
         <ns1:query/>
         <ns1:queryOptions/>
        </ns1:GetListItemsStr>
       </dfs:queryFields>
       <dfs:dataFields>
        <ns1:GetListItemsStrResponse>
         <ns1:GetListItemsStrResult>
          <Rows count="" next="" xd:PluggedNode="">
           <row>
            <Test_Serial_Number/>
            <Diameter/>
            <Tensile_Load_1_Ext/>
            <Tensile_Load_Ultimate/>
            <Tensile_Strength_1_Ext/>
            <Tensile_Strength_Ultimate/>
            <Torsions_A/>
            <Torsions_B/>
            <Elong/>
            <Wraps/>
           </row>
          </Rows>
         </ns1:GetListItemsStrResult>
        </ns1:GetListItemsStrResponse>
       </dfs:dataFields>
       <xd:SchemaInfo LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution">
        <xd:Namespaces>
         <xd:Namespace LocalName="myFields" NamespaceURI="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"/>
         <xd:Namespace LocalName="Rows" NamespaceURI=""/>
        </xd:Namespaces>
        <xd:RequiredAnys>
         <xd:RequiredAny SOM_Path="{http://qdabra.com/databaseservice}GetListItemsStrResponse/{http://qdabra.com/databaseservice}GetListItemsStrResult/##any[1]" NamespaceURI="" LocalName="Rows"/>
        </xd:RequiredAnys>
       </xd:SchemaInfo>

    </dfs:myFields>

    I copied this into the namespace:

    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-04-28T14:41:50" xmlns:ns1="http://qdabra.com/databaseservice" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003

    No change.  No errors thrown but no results returned either.

     

  • 07-09-2009 01:43 PM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    You definitely need the dfs and ns1 in your namespaces.

    Try using the following in your selectNodes("/dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResult/Rows/row")

     

  • 07-10-2009 06:19 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Thanks for all your help ladies and gentlemen.  But, it is still not working for me.  Anyone else have an idea?  I get no errors but it just doesn't return anything but let I know the DBXL portion is working correctly because it populates the bound table.

    PLEASE HELP.  I'm so sick of this thing at this point and it's Friday and it would be nice to not worry about it all weekend.

     Thanks in advance!!

  • 07-10-2009 07:34 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    It would help if you would post your most recent version of the script you are using. You have an alert in the first sample -- I'm going to guess you are using that to help debug. Does the alert display anything?

    Hilary Stoupa

  • 07-10-2009 07:44 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Gladly, 

    First the Namespace defnitions which I got out of the Samples file as you suggested:

    XDocument.GetDOM( "GetListItemsStr" ).setProperty( "SelectionNamespaces" , 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-04-28T14:41:50" xmlns:ns1="http://qdabra.com/databaseservice" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"'); 

    Then the script:

     I'm only trying to clone one field at this point for test but I actually will be cloning about 15 fields when it is working.

    And yes the Alerts are just for debugging and I get nothing in the alert.  it pops up but is blank.

    It never enters the WHILE loop which I think is because nodes is not being populated?

    I know it's simple but being new to this I am not getting it.

    function CTRL188_5::OnClick(eventObj)
    {
    // Get a copy of the main DOM node.
         var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").cloneNode(true);
         // Clear the main DOM nodes.
         XDocument.DOM.selectNodes("/my:myFields/my:group3/my:Test_Details").removeAll();
         // Copy nodes from 2DS to main DOM.
         var nodes = XDocument.GetDOM("GetListItemsStr").selectNodes("/dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResult//Rows/row");
         XDocument.UI.Alert(nodes.text);
         var node;
         while(node = nodes.nextNode())
         {
              clone.selectSingleNode("/my:HuInput").text = node.selectSingleNode("Test_Serial_Number").text;
              XDocument.UI.Alert(node.text);
              XDocument.View.ExecuteAction("xCollection::insert", "group4_7");
              //XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").appendChild(clone.cloneNode(true));
         }
     // Write your code here
    }

  • 07-10-2009 08:01 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    There is a typo in your xpath:

    /dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResult//Rows/row

    should be:

    /dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResult/Rows/row

    with just one "/" between GetListItemsStrResult and Rows. Try that.

    Hilary Stoupa

  • 07-10-2009 08:06 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Also, you might find this more helpful for debugging:

     XDocument.UI.Alert(nodes.length);

    Hilary Stoupa

  • 07-10-2009 08:12 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    My previous response left out the GetListItemsStrResponse in the xpath.

    "/dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResponse/ns1:GetListItemsStrResult/Rows/row"

    You may want to display the node.innerText inside the loop.

     

  • 07-10-2009 08:57 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Sucess!! Sort of.  I am now returning a valid record count on the alert.  Now on to actually working through the cloning part which I have not done before.

    The While Loop now executes and I get a valid string of the data back in an alert but the clone command is giving me the error: 'selectSingleNode(...)' is null or not an object.

    I'll work on it but if anyone can look at my script and spot it please let me know.

    var node;
         while(node = nodes.nextNode())
         {
              XDocument.UI.Alert(node.text);
              clone.selectSingleNode("/my:HuInput").text = node.selectSingleNode("Test_Serial_Number").text;
             
              //XDocument.View.ExecuteAction("xCollection::insert", "group4_7");
              //XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").appendChild(clone.cloneNode(true));
         }

     Thanks!!!!

     

  • 07-10-2009 09:14 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    selectSingleNode will return null if the node specified by the xpath is not found.  In this case you probably need to remove the '/' before my:HuInput so instead use selectSingleNode("my:HuInput")

  • 07-10-2009 09:14 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    First off, what does your main data structure look like? Is Test_Details a repeating group and my:HuInput a field in that group?

    If so, try:

    clone.selectSingleNode("my:HuInput").text = node.selectSingleNode("Test_Serial_Number").text;

    Hilary Stoupa

  • 07-10-2009 09:34 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Oh so close I think.

     Test_Details is a repeating table.  HuInput is a field in that repeating table.

    Maybe if I explain what I'm trying to do it will help.

    I need a repeating table in the main data source that I can load from the secondary data source based on a query field. (Thanks to all of you that part is working). I then need to be able to add additional items to this repeating table or delete items that were loaded based on the secondary data source.

    The goal is to save the user time be allowing them to use a common field to pull in perhaps 100 items or more instead of keying each one individually but then be able to remove select items that are added from the secondary.

  • 07-10-2009 09:59 AM In reply to

    Re: Copy/Clone data from DBXL Secondary Data Connection to InfoPath 2003 Repeating table in Main Data in JS

    Here's what I'd do. Please note that you are going to have to change the XPaths to match yours. For example, I added another field to my data source in the repeating Test_Details group called 'AnotherField'. Your's will have different names. Also, my ShP list has different columns.

         // Get a copy of the main DOM node.
         var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").cloneNode(true);
         // Clear the main DOM nodes.
         XDocument.DOM.selectNodes("/my:myFields/my:group3/my:Test_Details").removeAll();
         // Copy nodes from 2DS to main DOM.
         var nodes = XDocument.GetDOM("GetListItemsStr").selectNodes("/dfs:myFields/dfs:dataFields/tns:GetListItemsStrResponse/tns:GetListItemsStrResult/Rows/row");
         XDocument.UI.Alert(nodes.length);
         var node;
         while(node = nodes.nextNode())
         {
              var newTestDetails = clone.cloneNode(true);
              newTestDetails.selectSingleNode("my:HuInput").text = node.selectSingleNode("Title").text;
              newTestDetails.selectSingleNode("my:AnotherField").text = node.selectSingleNode("Status").text;
              XDocument.DOM.selectSingleNode("/my:myFields/my:group3").appendChild(newTestDetails);
         }
    Hilary Stoupa

Page 1 of 3 (39 items) 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.