Hi experts,
I have used scripting to run an active timer on field new_timer, triggered when any field changes on the form using getIsDirty()
I'm getting this scripting error, although I can't find any error in my code.

//Initialize time attributes
var seconds = 0, minutes = 0, hours = 0,t;
var myVar = setInterval(add, 2000);
function add()
{
//var flag = Xrm.Page.getAttribute("new_timerstatus").getValue();
//if (flag == "1")
//{
//get list of dirty fields
oppAttributes = Xrm.Page.data.entity.attributes.get();
if (var oppAttributes != null) {
for (var i in oppAttributes) {
if (oppAttributes[i].getIsDirty()) {
seconds++;
if (seconds >= 60) {
seconds = 0;
minutes++;
if (minutes >= 60) {
minutes = 0;
hours++;
}
}
clearTimeout(myVar);
}
}
}
//creating time value in hh:mm:ss formate
var tmp = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
Xrm.Page.getAttribute("new_timer").setValue(tmp);
//}
//recursively calling timer
timer();
}
//main timer method
function timer() {
t = setTimeout(add, 1000);
}
/*function onLoad()
{
Xrm.Page.getAttribute("new_timerstatus").setValue("1");
}*/
Please help me out as I'm unable to figure out the problem.
Thanks,
Jon
*This post is locked for comments
I have the same question (0)