Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript - InfoPath Dev
in

InfoPath Dev

Qdabra® DBXL

Use our Google Custom Search for best site search results.

Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

Last post 08-02-2012 04:11 PM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-01-2012 08:50 AM

    Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    Infopath 2007 / SharePoint 2010

     

    I have a form that is connected to a SharePoint list as a secondary data source. I need to get the record from this SharePoint List and populate The repeating table in main data connection. I am not permitted to use Any type of code except Jscript. I am stuck and not sure what i am doing wrong. I am getting an error at Line one

    1. // Get a copy of the main DOM node.     
    2.  var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:ProgramCapacity/my:Meetings/my:BAU_Meeting").cloneNode(true);     
    3.  // Clear the main DOM nodes.      
    4. XDocument.DOM.selectNodes("/my:myFields/my:ProgramCapacity/my:Meetings/my:BAU_Meeting ").removeAll();      
    5. // Copy nodes from 2DS to main DOM.      var nodes = XDocument.GetDOM("Meetings").selectNodes("/dfs:myFields/dfs:dataFields/dfs:Meetings");   
    6.   foreach(node in nodes)    
    7.            
    8. clone.selectSingleNode("@Meeting-Project_Name").text = node.selectSingleNode("BAU_Meetings").text;           
    9. XDocument.DOM.selectSingleNode("/my:myFields/my:ProgramCapacity/my:Meetings/my:BAU_Meeting").appendChild(clone.cloneNode(true));      
    10.  

     

    Main Data connection

    Secondary data Connection 

     Any help would be appreciated I am really new to this. Thanks

     

  • 08-01-2012 08:57 AM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    Your XPath is wrong:

    var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:ProgramCapacity/my:Meetings/my:BAU_Meeting").cloneNode(true);

    Should be:

    var clone = XDocument.DOM.selectSingleNode("/my:myFields/my:Program-Capacity/my:Meetings/my:BAU_Meeting").cloneNode(true);

     

    Hilary Stoupa

  • 08-01-2012 10:02 AM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    Thanks for that.

    Now I'm having issues with the Xpath of secondary data source it does not Recognize the dfs prefix.
  • 08-01-2012 04:43 PM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    I think you have to set the namespaces - I have a C# sample for that - sorry, I'm pretty pathetic at jscript, but maybe this will point you in the right direction:

    IXMLDOMDocument2 dom = (IXMLDOMDocument2)thisXDocument.GetDOM("DataSourceName");

    dom.setProperty("SelectionNamespaces", "xmlns:dfs='http://schemas.microsoft.com/office/infopath/2003/dataFormSolution'");

    Hilary Stoupa

  • 08-02-2012 08:26 AM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    I added the Reference to the name Space

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

    This resolved ths issue. for this situation

    But now it does not reconize the my I addded the Ref but it still does not work.

    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-07-26T17:23:36"');

  • 08-02-2012 08:36 AM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    There are a lot of sample forms here. Perhaps one will help you?

    Hilary Stoupa

  • 08-02-2012 01:09 PM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    I belive What have done here. http://www.infopathdev.com/blogs/hilary/archive/2008/07/04/how-do-i-copy-repeating-data-from-an-external-source-into-my-form.aspx will work for me pretty well. I am now trying to figure out how to adapt it to my needs. Thanks for the tip Hilary.  I guess my question is does the file have to be a resource file or can it be connected as a secondary data source.

    Thanks

    James

  • 08-02-2012 04:11 PM In reply to

    Re: Copy text from Secondary Datasource(Sharepoint list) to repeating table in the main data connection JScript

    Well, the resource file is a secondary data source, but I get what you mean - the difference between the resource file in that sample and the secondary data source you are using is that your 2ds has namespace prefixes.

    Hilary Stoupa

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