date - Dynamics CRM 2011: javascript, 'null' is null not an object. error -


i using javascript on dynamics crm 2011. trying create new field comparing 2 date fields. however, think wrong null value. cas error message shows up: 'null' null not object.

the following script. please have look, , let me know think.

function m1status() {      var m1date = xrm.page.getattribute("new_m1date").getvalue()      var today = xrm.page.getattribute("new_todayis").getvalue()      if (m1date == null) {          xrm.page.getattribute("new_m1status").setvalue('not booked');}      else if (m1date.gettime() >= today.gettime()) {          xrm.page.getattribute("new_m1status").setvalue('booked');}      else {          xrm.page.getattribute("new_m1status").setvalue('completed');}      //set submit mode     xrm.page.getattribute("new_m1status").setsubmitmode("always");  } 

also default value null. cas nothing shown up.

thanks much.

there typos in code, can rewrite code in way , fill missing actions.

function m1status() {      var m1date = xrm.page.getattribute("new_m1date").getvalue();     var today = xrm.page.getattribute("new_todayis").getvalue();      // can have 4 cases     // 1: both fields null     if (m1date == null && today == null) {         xrm.page.getattribute("new_m1status").setvalue('not booked');     }     // 2: both fields not null     if (m1date != null && today != null) {          if (m1date.gettime() >= today.gettime()) {             xrm.page.getattribute("new_m1status").setvalue('booked');         }         else {             xrm.page.getattribute("new_m1status").setvalue('completed');         }     }     // 3: first field not null, second field null     if (m1date != null && today == null) {         // need in case?     }     // 4: first field null, second field not null     if (m1date == null && today != null) {         // need in case?     }      xrm.page.getattribute("new_m1status").setsubmitmode("always"); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -