Run Time Error - InfoPath Dev
in

InfoPath Dev

Run Time Error

Last post 11-09-2011 02:32 PM by AzuDaioh. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-09-2011 02:15 PM

    Run Time Error

    I am using InfoPath 2003 w/SharePoint 2010.  The template works last week but for some reason after the DST ended, I get this error message:

    A run-time error has occurred.
    Do you want to bug?

    The following error occurred:

    'undefined' is null or not an object
    File: script.js
    Line 32.

    BTW, I only get the error message when I open an existing form.  If I open a blank form, I dont get the error message.

    Below is the code and line 32 is: var hour = now.getHours(); 

    var oRows2;
    var oSampleRow2;

    function XDocument::OnLoad(eventObj)
    {
     oRows2 = XDocument.DOM.selectNodes("/my:myFields/my:StepFour/my:s4Table");
     oSampleRow2 = oRows2.nextNode();
     XDocument.DOM.selectSingleNode("/my:myFields/my:field54").text = "false";
     
     
     if(XDocument.IsNew)
     var now = new Date();
     var hour = now.getHours();  //this is line 32
     var minute = now.getMinutes();
        var second = now.getSeconds();
        var monthnumber = now.getMonth() + 1;
        var monthday = now.getDate();
        var year = now.getYear();
        var oTimeStamp = monthnumber + " " + monthday + " " + year + " "+ hour + " " + minute + " " + second
     XDocument.DOM.selectSingleNode("/my:myFields/my:TimeStamp").text = oTimeStamp;
    }

     

    Any help is greatly appreciated. Thank you.

    Azu

  • 11-09-2011 02:25 PM In reply to

    Can you double check that script code?  The if(XDocument.IsNew) doesn't have a curly brace '{' and I would expect it to look more like this:

    var oRows2;
    var oSampleRow2;

    function XDocument::OnLoad(eventObj)
    {
    oRows2 = XDocument.DOM.selectNodes("/my:myFields/my:StepFour/my:s4Table");
    oSampleRow2 = oRows2.nextNode();
    XDocument.DOM.selectSingleNode("/my:myFields/my:field54").text = "false";
     

     if(XDocument.IsNew)

    { // Added left-curly brace
     var now = new Date();
    var hour = now.getHours(); //this is line 32
    var minute = now.getMinutes();
    var second = now.getSeconds();
    var monthnumber = now.getMonth() + 1;
    var monthday = now.getDate();
    var year = now.getYear();
    var oTimeStamp = monthnumber + " " + monthday + " " + year + " "+ hour + " " + minute + " " + second
    XDocument.DOM.selectSingleNode("/my:myFields/my:TimeStamp").text = oTimeStamp;

    } // Added right-curly brace

    }

  • 11-09-2011 02:32 PM In reply to

    Yup. It was missing the curly brackets. It's always the curly brackets...thanks Jim!!!

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