Null or is not an object RRS feed

  • Question

  • I have added a field credit status.  There is an attribute statuscode with values 1, 200000 (credit watch), 200001 (credit hold).  I am trying to check in the account onload event

    if (crmForm.all.statuscode.DataValue == 1)

    { Code to set the credit status field}

    else if (crmForm.all.statuscode.DataValue == 20000)

    { Code to set the credit status field}

    else if (crmForm.all.statuscode.DataValue == 20001)

    { Code to set the credit status field}

    I am getting an error

    There was an error with the field's customized event
    Error:'crmForm.all.statuscode.Datavalue' is null or not an object

    I tried to check for null, I am still getting the same error.  I checked the dabases, the field statuscode has values in it.

    Thanks for the response.


    Thursday, May 26, 2011 3:48 PM


All replies

  • Note the case of Datavalue, JavaScript is a case sensitive language. It should be DataValue. Your code looks correct, but the error message does indicate that you have got wrong case somehow.  
    Daniel Cai | http://danielcai.blogspot.com
    Thursday, May 26, 2011 3:53 PM
  • Thanks.  The error message shows Error:'crmForm.all.statuscode.DataValue' is null or not an object.  I did not type it right.
    Thursday, May 26, 2011 3:58 PM
  • Is the statuscode field on the form? It has to be on the form in order for you to access its value.
    Daniel Cai | http://danielcai.blogspot.com
    • Proposed as answer by Jamie MileyModerator Thursday, May 26, 2011 4:10 PM
    • Marked as answer by SN_NJ Friday, May 27, 2011 1:16 PM
    Thursday, May 26, 2011 4:03 PM
  • Thanks.  I found that out yesterday and included the statuscode as a field that is not displayed.  But the new field still is not displaying the value.  I had entered the code in On load event.   Iam trying to troubleshoot by writing the code

    alert("Entered statuscode check");

    Is there a way to debug JavaScript error in MSCRM?

    Friday, May 27, 2011 1:35 PM
    • Marked as answer by SN_NJ Friday, May 27, 2011 1:55 PM
    Friday, May 27, 2011 1:44 PM