Not able to insert row with "Undefined" as error message - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Not able to insert row with "Undefined" as error message

Last post 04-22-2010 08:15 AM by vriyer. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 04-22-2010 08:15 AM

    • vriyer
    • Not Ranked
    • Joined on 04-14-2010
    • Posts 6

    Not able to insert row with "Undefined" as error message


    I am trying to copy an secondary XML list from the SP into Main DOM.. I did the coding per the example I've seen from here using jscript.. The problem here is - I could see the variable value received from the list and it errors with a message "undefined" when it tries to insert.. Here is code I have.. Can someone please help?

     * This file contains functions for data validation and form-level events.
     * Because the functions are referenced in the form definition (.xsf) file,
     * it is recommended that you do not modify the name of the function,
     * or the name and number of arguments.

    // The following line is created by Microsoft Office InfoPath to define the prefixes
    // for all the known namespaces in the main XML data file.
    // Any modification to the form files made outside of InfoPath
    // will not be automatically updated.
    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="" xmlns:xhtml="" xmlns:my="" xmlns:xd=""');

    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    function CTRL786_45::OnClick(eventObj)

     // Get the Project Id.
     var selectedType = XDocument.DOM.selectSingleNode("/my:myFields/my:Project/my:Summary/my:Proj_ID").text;

     // If no form was selected notify the user.
     if(selectedType == "")
      XDocument.UI.Alert("Please enter a Project ID first.");
     XDocument.UI.Alert("Project ID" + selectedType);
     // Get the list per the selected Project Id.
     var vehicles =XDocument.GetDOM("Phase_Metrics_XML").selectNodes("/ROWSETS/ROWSET1/ROW[PROJECT_ID = '" + selectedType + "']");

     // If nothing was found, then return; there will be no items to insert. 
     if(vehicles == null)
     // Get the insertion point.
     var vehicleList = XDocument.DOM.selectSingleNode("/my:myFields/my:Financial");

     // Add the rows to the main DOM.
     var vehicle;
     while(vehicle = vehicles.nextNode())
       // Get the values from the secondary DOM.
       var phaseName = vehicle.selectSingleNode("PHASE_NAME").text;
       var phaseStart = vehicle.selectSingleNode("PHASE_START").text;
       var phaseFinish = vehicle.selectSingleNode("PHASE_FINISH").text;
       var phaseAct = vehicle.selectSingleNode("PHASE_ACT_COST").text;
       var phaseETC = vehicle.selectSingleNode("PHASE_ETC_COST").text;
       var phaseWeeks = vehicle.selectSingleNode("TOTAL_WEEKS").text;
       var phaseEstBurn = vehicle.selectSingleNode("TOTAL_BURN").text;
       var phaseActBurn = vehicle.selectSingleNode("ACTUAL_BURN").text;
       XDocument.UI.Alert("Vars " + phaseName);

       // Build a string representing a main DOM vehicle nodeset using the values from the secondary DOM.
       var vehicleXml = "<my:Phase_Detail xmlns:my=''>"
           + "<my:Phase_Name>" + phaseName + "</my:Phase_Name>"
           + "<my:Phase_Start>" + phaseStart + "</my:Phase_Start>"
           + "<my:Phase_Finish>" + phaseFinish + "</my:Phase_Finish>"
           + "<my:Phase_Actuals>" + phaseAct + "</my:Phase_Actuals>";
           + "<my:Phase_ETC>" + phaseETC + "</my:Phase_ETC>";
           + "<my:Phase_Duration>" + phaseWeeks + "</my:Phase_Duration>";
           + "<my:Phase_Est_Burn>" + phaseEstBurn + "</my:Phase_Est_Burn>";
           + "<my:Phase_Act_Burn>" + phaseActBurn + "</my:Phase_Est_Burn>";
       vehicleXml += "</my:Phase_Detail>" ;

       // Load new vehicle string into a temporary XML DOM.
       var domNewRow = XDocument.CreateDOM();
       domNewRow.validateOnParse = false;
       domNewRow.async = false;
       domNewRow.setProperty("SelectionNamespaces", 'xmlns:xsi="" xmlns:xhtml="" xmlns:my="" xmlns:xd=""');
       // domNewRow.setProperty("SelectionNamespaces", 'xmlns:my=""');
       // Insert the new vehicle into the main DOM.
       XDocument.UI.Alert("Could not insert row.\n\nError message:\n" + ex.Message);

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