Hi All, I implemented an script of Timer in Case Entity form in which when a case is opened then timer would be started from 00:00:00. This is working fine but i noticed an strange or misbehavior of that timer functionality which is when I am going to create a new case record and hit Save button to save that record then timer increases rapidly like 1-3-5-... or sometimes 123456789. But using same script if I reopen the same case record then this is working fine. So, i think there is some issue with Save button or maybe something else. Please suggest for the same? var seconds = 0, minutes = 0, hours = 0,t; var isDirtyForm = false; function add() { isDirtyForm = Xrm.Page.data.entity.getIsDirty(); var flag = Xrm.Page.getAttribute("new_timerstatus").getValue(); if(isDirtyForm===true) { if (flag == "1") { seconds++; if (seconds >= 60) { seconds = 0; minutes++; if (minutes >= 60) { minutes = 0; hours++; } } } //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"); Xrm.Page.getAttribute("new_checkstatus").setValue("Live"); }
↧