in

InfoPath Dev

Copy text from one repeating table to another

Last post 07-25-2008 05:47 AM by eirike. 37 replies.
Page 3 of 3 (38 items) < Previous 1 2 3
Sort Posts: Previous Next
  • 06-09-2008 02:35 AM In reply to

    Re: Copy text from one repeating table to another

    Deleted and posted

  • 06-10-2008 05:30 AM In reply to

    • DMcKinnon
    • Not Ranked
      Male
    • Joined on 06-10-2008
    • Raleigh, NC
    • Posts 3

    Re: Copy text from one repeating table to another

    I have been trying to implement the code here to copy a secondary data source (SharePoint list) to the main data source. The problem is the code is telling me that "node" is undeclared and will not run. If I put "var" in front of "node" it throws a syntax error, and I haven't been able to determine what exactly I am missing.
    I am using JavaScript and IP 2003.

    //NAMESPACESDEFINITION
         XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dfs=http://schemas.microsoft.com/office/infopath/2003/dataFormSolution
         xmlns:my=http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-05-27T15:30:14
         xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"'); XDocument.GetDOM("Retirement Core Activities").setProperty
            ("SelectionNamespaces",'xmlns:ns1="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"' );
    // /NAMESPACESDEFINITION

    function CTRL273_5::OnClick(eventObj) {
         // Get a copy of the main DOM node. 
         var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:group7/my:group8").cloneNode(true); 
         // Clear the main DOM nodes.
         XDocument.DOM.selectNodes("/my:myFields/my:group7/my:group8").removeAll();
         // Copy nodes from 2DS to main DOM.
         var nodes = XDocument.GetDOM("Retirement Core Activities").selectNodes("/ns1:myFields/ns1:dataFields/ns1:Retirement_Core_Activities");
         foreach(node in nodes)
         {
              clone.selectSingleNode("/my:CoreStatus").text = node.selectSingleNode("STATUS").text;
              clone.selectSingleNode("/my:CoreCompletedDate").text = node.selectSingleNode("COMPLETED_DATE").text;
              clone.selectSingleNode("/my:CoreTechLead").text = node.selectSingleNode("TECH_LEAD").text;
              XDocument.DOM.selectSingleNode("/my:myFields/my:group7/my:group8").appendChild(clone.cloneNode(true));
         }
    }

    Filed under: ,
  • 06-10-2008 06:10 AM In reply to

    Re: Copy text from one repeating table to another

    Hi,

    i might be wrong but are you sure your 'nodes' definition is pointing to the repeating table itself?

     

      var nodes = XDocument.GetDOM("Retirement Core Activities").selectNodes("/ns1:myFields/ns1:dataFields/ns1:Retirement_Core_Activities");

    in the codes it write it's more like..

    var nodes2=XDocument.GetDOM("list_machines").selectNodes("/dfs:myFields/dfs:dataFields/ns2:Landesk_listResponse/ns2:Landesk_listResult/NewDataSet/Table") 

    have a look at the screenshot of my secondary datasource at url below

     http://www.infopathdev.com/forums/p/7371/26922.aspx#26922

     (or search for "scarse information on passing parameter to a secondary datasource" in the forums)

    my secondary datasource is based on a table returned (Landesk_listResponse) as a result (Landesk_listResult) of a query.

    That's not what i can see in your code.

     

    KriZ
  • 06-10-2008 06:30 AM In reply to

    • DMcKinnon
    • Not Ranked
      Male
    • Joined on 06-10-2008
    • Raleigh, NC
    • Posts 3

    Re: Copy text from one repeating table to another

    Thanks for the reply knudde,
          I am reasonably sure "nodes" is getting populated. If I wrap the foreach statement in if(nodes.length > 0) the foreach still runs and throws the error. If I change 0 to 100 the foreach does not run.
          I did try your suggestion but in that case if I again wrap the foreach statement with the if it no longer runs for nodes.length > 0 making me believe that is not the right approach for interfacing with a sharepoint list.

    Thanks for your help

  • 06-17-2008 03:51 PM In reply to

    Re: Copy text from one repeating table to another

    DMcKinnon, when you do a foreach, you need to include the data type of the single item:

    foreach(IXMLDOMNode node in nodes)

    Nevermind--that's for C#. I see you are using JScript. You cannot use foreach in JScript the way you are using it. Try this:

    var node;
    while(node = nodes.nextNode())
    {
    ...
    }

    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 06-18-2008 05:01 AM In reply to

    • DMcKinnon
    • Not Ranked
      Male
    • Joined on 06-10-2008
    • Raleigh, NC
    • Posts 3

    Re: Copy text from one repeating table to another

    Thanks Greg, I will have to try it and see if that works.

    Update: Thanks a lot Greg, that seemed to be my lynch pin problem, after fixing that and a few other minor fixes I was able to get it working perfectly.

    Thanks again

  • 06-19-2008 10:10 AM In reply to

    Re: Copy text from one repeating table to another

    Great! Glad to hear you got it working!

    Visit my Web site:

    http://www.braintrove.com

    Greg Collins / Microsoft MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-25-2008 05:47 AM In reply to

    • eirike
    • Not Ranked
    • Joined on 07-25-2008
    • Posts 3

    Re: Copy text from one repeating table to another

    Hi.

    I have problems with this.. Could you please help?

    here is my code...

     

    public void CTRL19_5_Clicked(object sender, ClickedEventArgs e)

    {

    XPathNavigator rootMain = MainDataSource.CreateNavigator().SelectSingleNode("/my:MineFelt/my:Selected/my:Selected2", NamespaceManager);

    XPathNavigator rootSecondary = this.DataSources["getStorfeIDyrehold"].CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:getStorfeIDyreholdResponse/tns:getStorfeIDyreholdResult/storfeListe", NamespaceManager);

    XPathNodeIterator selectnodes = rootSecondary.Select("getStofeIDyrehold", NamespaceManager);

    XmlWriter writer = rootMain.SelectSingleNode("/my:MineFelt/my:Selected/my:Selected2", NamespaceManager).AppendChild();

    string myNameSpace = NamespaceManager.LookupNamespace("my");foreach (XPathNavigator node in selectnodes)

    {

    writer.WriteStartElement("S_dyrehold", myNameSpace);

    writer.WriteElementString("S_opprMerkeDyrehold", myNameSpace, node.GetAttribute("S_opprMerkeDyrehold", ""));writer.WriteElementString("S_dodsdato", myNameSpace, node.GetAttribute("S_dodsdato", ""));

    writer.WriteEndElement();

     

    }

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