locked
CRM 4.0 Email Regarding Field. Error:'0' is null or not an object RRS feed

  • Question

  • I would like to check the email regarding field in order to hide the message field. I am getting an error with the following code.

    Error:'0' is null or not an object

    Any ideas on what is incorrect?  Thanks

    gHideField = function (name){ 
         var field = document.getElementById(name+'_d');
         var fieldcapt = document.getElementById(name+'_c');
         if(field != null){field.style.display='none';}
         if(fieldcapt != null){fieldcapt.style.display='none';}
     };

    var TheRegarding = new Array;
    TheRegarding = null;

    TheRegarding= crmForm.all.regardingobjectid.DataValue;

    if (TheRegarding[0]== null) {

        gHideField ('description');

    }

    Thursday, February 24, 2011 7:48 PM

Answers

  • TheRegarding= crmForm.all.regardingobjectid.DataValue;

    if (TheRegarding[0]== null) {

        gHideField ('description');

    }

    If a Lookup field has no value set, the DataValue will be null, thus:

    TheRegarding = crmForm.all.regardingobjectid.DataValue;
    
    if (TheRegarding == null) {
      gHideField ('description');
    }
    


    --pogo (pat)
    • Proposed as answer by Jim Glass Jr Thursday, February 24, 2011 9:51 PM
    • Marked as answer by NC_Matthews Friday, February 25, 2011 12:19 PM
    Thursday, February 24, 2011 9:45 PM

All replies

  • Hi, Try to replace this:
    if (TheRegarding[0]== null) {
       gHideField ('description');
    }

    for this:
    if (TheRegarding[0].id== null) {
       gHideField ('description');
    }


    Julio

    Thursday, February 24, 2011 7:53 PM
  • No, I still get the same error. 
    Thursday, February 24, 2011 8:09 PM
  • Try this:

    gHideField = function (name){ 
         var field = document.getElementById(name+'_d');
         var fieldcapt = document.getElementById(name+'_c');
         if(field != null){field.style.display='none';}
         if(fieldcapt != null){fieldcapt.style.display='none';}
     };

    if(crmForm.all.regardingobjectid!=null){
    if (crmForm.all.regardingobjectid.DataValue[0].id== null) {

        gHideField ('description');

    }
    }


    Julio
    Thursday, February 24, 2011 8:43 PM
  • No, simular error

    Error:'crmForm.all.regardingobjectid.DataValue.0' is null or not an object

    Thursday, February 24, 2011 9:01 PM
  • TheRegarding= crmForm.all.regardingobjectid.DataValue;

    if (TheRegarding[0]== null) {

        gHideField ('description');

    }

    If a Lookup field has no value set, the DataValue will be null, thus:

    TheRegarding = crmForm.all.regardingobjectid.DataValue;
    
    if (TheRegarding == null) {
      gHideField ('description');
    }
    


    --pogo (pat)
    • Proposed as answer by Jim Glass Jr Thursday, February 24, 2011 9:51 PM
    • Marked as answer by NC_Matthews Friday, February 25, 2011 12:19 PM
    Thursday, February 24, 2011 9:45 PM
  • I would like to check the email regarding field in order to hide the message field. I am getting an error with the following code.

    Error:'0' is null or not an object

    Any ideas on what is incorrect? Thanks

    gHideField = function (name){
    var field = document.getElementById(name+'_d');
    var fieldcapt = document.getElementById(name+'_c');
    if(field != null){field.style.display='none';}
    if(fieldcapt != null){fieldcapt.style.display='none';}
    };

    var TheRegarding = new Array;
    TheRegarding = null;

    TheRegarding= crmForm.all.regardingobjectid.DataValue;

    if (TheRegarding[0]== null) {

    gHideField ('description');

    }


    Could you pls give more explanation on your needs? It will be better for helping you.
    Saturday, March 26, 2011 3:11 AM