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

InfoPath Dev

Use our Google Custom Search for best site search results.

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 3 of 3 (39 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 07-14-2009 08:10 AM In reply to

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

    Hey, could you also post the most recent copy of your script, in case there is something else going wrong? Because the field should be there, even if it doesn't have data...so it seems like something else might be the problem.

    Hilary Stoupa

  • 07-14-2009 08:20 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 the current script.  I added the Alert for the length of the node just for debuggin.  It will show me the node size for the records just fine up until it hits that one where this none has not been filled in yet and I Object Required.

    I had already tried to test for null just like mentioned:

     var field = node.selectSingleNode("Diameter");

    but this line will error out with object required.

    So I was trying to use the length thinking that if it was zero I could identify it that way but it still comes back with object required.

     

    / Get a copy of the main DOM node.
         var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:group3/my:Test_Details").cloneNode(true);
         // Copy nodes from 2DS to main DOM.
         var nodes = XDocument.GetDOM("GetListItemsStr").selectNodes("/dfs:myFields/dfs:dataFields/ns1:GetListItemsStrResponse/ns1:GetListItemsStrResult/Rows/row");
                  
         var node;
        
         while(node = nodes.nextNode())
         {
              var newTestDetails = clone.cloneNode(true);
              newTestDetails.selectSingleNode("my:field10").text = node.selectSingleNode("Test_Serial_Number").text;
          
        //newTestDetails.selectSingleNode("my:field11").text = node.selectSingleNode("Diameter").text;
       
       
        var field11 = newTestDetails.selectSingleNode("my:field11");
        XDocument.UI.Alert(node.selectSingleNode("Diameter").text.length);
        if (node.selectSingleNode("Diameter").length != 0)
        {
        var diameter = node.selectSingleNode("Diameter").text;
        if (diameter != "" & field11.getAttribute("xsi:nil"));
        field11.removeAttribute("xsi:nil");
        field11.text = diameter;
        }
        XDocument.DOM.selectSingleNode("/my:myFields/my:group3").appendChild(newTestDetails);
         }
     // Write your code here
    }

     

     

  • 07-14-2009 08:40 AM In reply to

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

    Your script is different from my sample. You are selecting the text of the node. If the node is null, you'll get an object required error when you try to select text.

    So, what you have:

       var field11 = newTestDetails.selectSingleNode("my:field11");
        XDocument.UI.Alert(node.selectSingleNode("Diameter").text.length);
        if (node.selectSingleNode("Diameter").length != 0)
        {
        var diameter = node.selectSingleNode("Diameter").text;
        if (diameter != "" & field11.getAttribute("xsi:nil"));
        field11.removeAttribute("xsi:nil");
        field11.text = diameter;
        }

    Could be:

    var field11 = newTestDetails.selectSingleNode("my:field11");
    var diameter = node.selectSingleNode("Diameter")
    //check to see if the diameter node is null
    if (null != node.selectSingleNode("Diameter"))
    {
     //if it isn't null, check to see if the field has a value
        if (diameter.text != "")
        {
            //if the field has a value, check for the nil attribute
            if(field11.getAttribute("xsi:nil"))
            {
                //remove nil if present
                field11.removeAttribute("xsi:nil");
            }
            //set the field to the diameter value if diameter.text has a value
            field11.text = diameter.text;
        }
    }
    Hilary Stoupa

  • 07-14-2009 08:56 AM In reply to

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

    Well Hillary to not be a Java Script girl you are doing wonderfully.  That did it.  I had tried similar combinations all around that but had not hit that combination I guess.

     Works like a charm. Now lets try and add all the other fields and see what I get into!

     I'll leave you alone for the rest of today unless I hit some huge roadblock.

    Thanks Again!!!

  • 07-14-2009 12:26 PM In reply to

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

    OK.  I lied!  Well not really.  I have progressed nicely since this morning.  Everything is going fine but I moved on to finishing the code for this.  What I now need to do is combine the query function to DBXL with the rest of the code. 

    I had been doing the query in Rules but now I want to call the query from script instead so I can do it in one click.  I know that query builder makes code to insert in code but what I can't seem to do is set the query field in the DBXL connection from script so that I can then execute the query and get the results back.

    Again, I'm sure it's simple but in my search in infopathdev I have not found what I'm trying to do so far.

    I'm thinking we're talking one or two lines of code to set the query field(currently performed in a rul) to the query string. Then code to cause the query to the DBXL connection to occur.

    Thanks again and I hope that all my grief benefits other vistors to this forum!

  • 07-14-2009 02:19 PM In reply to

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

    For example:

      var query = XDocument.GetDOM("GetListItemsStr").selectSingleNode("/dfs:myFields/dfs:queryFields/tns:GetListItemsStr/tns:query");
     
      query.text = "<query><filter><eq><column name='Title'/><value>Test</value></eq></filter></query>"
     
      XDocument.DataObjects["GetListItemsStr"].Query();

    The first line gets the 'query' field in the queryFields of the data connection. The second line sets the value to our new query (mine filters out any items that don't have title equal to Test) and the third actually executes the query to retrieve the data. Hope that helps!

    Hilary Stoupa

  • 07-15-2009 08:00 AM In reply to

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

    Thanks Hillary.  The static query works but I need to pass a variable to the query.  I have tried to concat everyway I can think of the string to pull in the input field which is in the main.  I copied the code generated by Query Builder and I copied the piece of code that I was using in the Rule to set the query field of the secondary DBXL but the script will blow for various reasons. I've used


    xdXDocument:get-DOM()/my:myFields/my:TopLevelInput

     which is what Query Builder generates but when I put this in the form will not load with a "expecting )" error but I am not missing any right parens. I've tried using the

    XDocument.DOM.selectSingleNode("/my:myFields/my:TopLevelInput")

    They either blow on form load or if the form loads then when it executes it get an Object Required error.

    I swear I have never had this much trouble with code before!  I wrote COBOL for years and then VB but this script stuff is crazy!!!

    Thanks for your help!!!

  • 07-15-2009 08:18 AM In reply to

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

    Just get your main data source field value the way you have other main data source fields in your script:

    var field = XDocument.DOM.selectSingleNode("/my:myFields/my:TopLevelInput");

    Then, you can do something like this:

    query.text = "<query><filter><eq><column name='Title'/><value>" + field.text + "</value></eq></filter></query>";

    Hilary Stoupa

  • 07-15-2009 08:23 AM In reply to

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

    I had tried almost the same thing but did not have the .text in building the string.

     

    Thank you Thank you Thank you!!

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