Batch Undefined Error - InfoPath Dev
in

InfoPath Dev

Batch Undefined Error

Last post 12-30-2011 10:04 AM by ChrisMurphy. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 03-14-2011 10:24 AM

    Batch Undefined Error

     Hi I am doing a SharePoint/InfoPath site and when I click my submit button I get an error that says Batch is Undefined. Below is a copy the code that is throwing the error

     batch.selectSingleNode("/Batch/Method/Field[@Name='ID']").text = ID;

     

    Any help would be appreciated

     

    -The batch is stored as a resource file and a data connection

  • 03-14-2011 11:14 AM In reply to

    Hi --

    It would help to see the code prior to this line as well, since the undefined error makes me think that you've not initialized the variable named "batch".

     

    Hilary Stoupa

  • 03-15-2011 07:13 AM In reply to

    Hello the entire code is below

    function ListSubmit(xCAML,submitx)

    { var root = XDocument.DOM;

    var ID = root.selectSingleNode("my:myFields/my:ID").text;

    var Name = root.selectSingleNode("my:myFields/my:Name").text;

    var From = root.selectSingleNode("my:myFields/my:From").text;

    var To = root.selectSingleNode("my:myFields/my:To").text;

    var Computers = root.selectSingleNode("my:myFields/my:Computers").text;

    var Projectors = root.selectSingleNode("my:myFields/my:Projectors").text;

    var Cameras = root.selectSingleNode("my:myFields/my:Cameras").text;

    var Comments = root.selectSingleNode("my:myFields/my:Comments").text;

    var Location = root.selectSingleNode("my:myFields/my:Location").text;

    var LaptopCharger = root.selectSingleNode("my:myFields/my:LaptopCharger").text;

    var Clicker = root.selectSingleNode("my:myFields/my:Clicker").text;

    // Set the SharePoint ID

    batch.selectSingleNode("/Batch/Method/Field[@Name='ID']").text = ID; < line that is throwing the batch undefined error>

    // Set the Rerservers Name

    batch.selectSingleNode("/Batch/Method/Field[@Name='Title']").text = Name;

    // Set the From Date

    batch.selectSingleNode("/Batch/Method/Field[@Name='Check_x0020_Out_x0020_From']").text = From;

    // Set the To Date

    batch.selectSingleNode("/Batch/Method/Field[@Name='Check_x0020_Out_x0020_Date']").text = To;

    // Set the Computers

    batch.selectSingleNode("/Batch/Method/Field[@Name='Computer']").text = Computers;

    // Set the Projectos

    batch.selectSingleNode("/Batch/Method/Field[@Name='Projector']").text = Projectors;

    // Set the Cameras

    batch.selectSingleNode("/Batch/Method/Field[@Name='Digital_x0020_Camera']").text = Cameras;

    // Set the Comments batch.selectSingleNode("/Batch/Method/Field[@Name='Comments']").text = Comments;

    // Set the Location

    batch.selectSingleNode("/Batch/Method/Field[@Name='Location']").text = Location;

    // Set the Laptop Charger

    batch.selectSingleNode("/Batch/Method/Field[@Name='Laptop_x0010_Chargers']").text = LaptopCharger;

    // Set the Clicker

    batch.selectSingleNode("/Batch/Method/Field[@Name='Clickers']").text = Clicker;

    // Submit the item details to the web service to update the list

    XDocument.DataAdapters[submitx].Submit(); }

    //======= // 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 CTRL16::OnClick(eventObj)

    { var error = XDocument.Errors.Count;

    if(error !=0)

    {

    objError = XDocument.Errors(0); //pinpoin data validation error and return alert

    XDocument.UI.Alert("Error message: " + objError.ShortErrorMessage);

    }

    else

    {

    //if (XDocument.Dom.selectSingleNode("my:myFields/my:ID").text==[""]) //Prevent a 2nd attempt Submit if an ID has been assigned

    //{

    //if (!(XDocument.Dom.selectSingleNode("my:myFields/my:Project_Name").text==[""])) //Prevent initial Submit if no Project Name has been assigned

    //{

    //var submit1confirm=0

    ListSubmit("SubmitBatch","Web Service Submit");

    XDocument.DOM.selectSingleNode("my:myFields/my:submitrules").text = 1;

    }

    }

  • 03-15-2011 10:25 AM In reply to

    See how you are defining all your other variables -- var ID, etc? You aren't defining "batch" anywhere.

    Hilary Stoupa

  • 03-15-2011 11:04 AM In reply to

     In the Infopath form I have the batch as a resource file as well as a data connection to the batch as well as in the web service submit. where would i define the batch in the script. any suggestions

  • 03-15-2011 11:40 AM In reply to

    You are using a variable called "batch" - you need to define it in the script just like you define "ID".

    So, something like var batch = XDocument.GetDOM("Batch")

    With Batch replaced with the actual data source name of your data connection to your resource file.

    Hilary Stoupa

  • 03-15-2011 12:05 PM In reply to

     thank you i will try and respond if it works or not

  • 03-15-2011 03:26 PM In reply to

    Try this:

    //get the CAML
    XPathNavigator batch = DataSources["CustomListCAML"].CreateNavigator();

    Josée Sévigny
  • 03-15-2011 06:01 PM In reply to

    But that is C#, for IP 2007, and assumes that his data source is called "CustomListCAML". The original poster's code sample is jscript, thus using the 2003 OM.

    Hilary Stoupa

  • 12-30-2011 10:04 AM In reply to

    var batch = XDocument.DataObjects["NewItemXML"].DOM;
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.