function time()
{
var stdate = Xrm.Page.getAttribute("new_starttime").getValue();
var endate = Xrm.Page.getAttribute("new_finishtime").getValue();
if(stdate == null && endate == null)
{ alert(“Please enter the Start Time / Finish Time…”);
return false;
}
else if(stdate==null)
{ alert(“Please enter the Start Time !”);
return false;
}
else if(endate==null)
{ alert(“Please enter the Finish Time !”);
return false;
}
var st=stdate.getTime();
var ed=endate.getTime();
var sdiff=(ed-st);
var h=(sdiff/60/1000);
var p=parseInt(h);
var tm=p.toString();
Xrm.Page.getAttribute("new_timespent").setValue(tm);
}
Above code is for making two calculated fields Starting Date/time(when record is created) and Ending Date/time(current time of system). Then we make third different field which is Time Spent which is also calculated field. So, check the code for error free and if there are another way to make the calculated field send me link.
*This post is locked for comments
I have the same question (0)