InfoPath form error when connecting to data source - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

InfoPath form error when connecting to data source

Last post 06-23-2008 01:37 PM by Hilary Stoupa. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-30-2008 08:33 PM

    InfoPath form error when connecting to data source

    Hi Guys, Im new to this forum and new to InfoPath...

    I have written the function below which uses a secondary datasource(Project Metrics Retrieval) to populate fields in my form. This should match the project name in the form text box with the project name in the SharePoint list, then output the project agreed budget for that project.

    Hope my code makes sense(new to coding).

    function projectNameEqualsExistingProject()
    {
    var doc = XDocument.DataObjects("Project Metrics Retrieval").DOM;

    doc.setProperty("SelectionNamespaces",'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' + ' xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');

     var selectedField = XDocument.DOM.selectSingleNode("//my:projectName").text;

    var selectedNode = doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Project_Metrics_Library/@Project_Name=['selectedField']");

    XDocument.DOM.selectSingleNode("//my:ProjectAgreedBudget").text = selectedNode.getAttribute.getNamedItem("ProjectAgreedBudget");

    }

     The error i get is below:

    Expected token 'EOF' found '='.

    /dfs:myFields/dfs:dataFields/dfs:Project_Metrics_Library/@Project_Name-->=<--['selectedField']

    I would also like to ask if there is a need to put a loop in there to navigate the list and look for the project name, or the this will automatically search for the project name?

     

    Thanks in advance...


  • 06-23-2008 01:37 PM In reply to

    Re: InfoPath form error when connecting to data source

    Hi, Charlie:

    I would expect this line:

    var selectedNode = doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Project_Metrics_Library/@Project_Name=['selectedField']");

    to look more like this:

    var selectedNode = doc.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:Project_Metrics_Library[@Project_Name='" + selectedField + "']");

    This will select the Project_Metrics_Library node that has a Project_Name attribute that matches the value in your selectedField variable.As long as each Project_Metrics_Library has a unique Project_Name attribute you will get just the node that matches the selectedField.

    Hilary Stoupa

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