I am creating one task from account entity record using javascript iam facing one issue while setting Date and Time field to Current date and time +5 hours it's not coming time correctly some random time is coming. But same piece of code is working fine when setting field while working on task record .here is the code I have written.
function TaskCreation() {
var Task = {};
Task.Subject = "Followup Call";
Task.Description = "this task was created for the regarding account for followup activity";
var currentDate = new Date();
currentDate.setHours(currentDate.getHours() + 5);
Task.ScheduledEnd = currentDate;
Task.RegardingObjectId = { Id: Xrm.Page.data.entity.getId(), LogicalName: 'account', Name: 'accountname' };
SDK.REST.createRecord(
Task,
"Task",
function (Task) {
writeMessage("The Task with Subject \"" + Task.Subject + "\" was created");
},
errorHandler
);
}
function errorHandler(error) {
writeMessage(error.message);
}
Same code is working fine when working from task record i.e
function Notify() {
var currentDate = new Date();
currentDate.setHours(currentDate.getHours() + 5);
alert(currentDate );
Xrm.Page.getAttribute("scheduledend").setValue(currentDate);
}
please tell me why same piece of code behaving differently??







