Date time format issue in CRM 2015 when using oData SDK.JQuery.retrieveRecordSync

When retrieving data in CRM using JQuery datetime comes back in int format with some back/forward slash.

Below is sample script how to remove back clash and forward slash and then covert to proper date time. Once converted we can compare two date times.

var result = SDK.JQuery.retrieveRecordSync(Context.newValues.MyItemId, “rok_abc”, “rok_xyz”, null);

dt = result.abc;
dt = dt.replace(“/Date(“, “”);
dt = dt.replace(/\\/g, “”);
dt = dt.replace(“)”, “”);
dt = dt.replace(/\//g, “”);
var promisedDt = new Date(parseInt(dt, 10));
var startDt = new Date(parseInt(Date.parse(Context.newValues.StartTime), 10));

if (startDt > promisedDt)
{
alert(‘We are cool’);
}

Comments are closed.