need a way to stop time worked on new records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2017 02:21 PM
My users are complaining that when they create a new record, such as a scrum task, the time worked timer is started by default. Thus, they are getting very small increments of time logged to items that they have only created a record for, but not worked on. Is there a way to disable the timer from starting automatically when a new record is created?
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2017 08:55 PM
Hi Michael,
Please try the below code in an onload client script. In my case,table selected is incident and type is onload
function onLoad() {
if(g_form.isNewRecord()){
if(g_form.getElement('time_worked')){
toggleTimer('time_worked','00:00:00');
}
}
function toggleTimer(fieldName,timerVal){
try{
//Get the necessary timer elements for fieldName given
var timerEl = $('element.' + g_form.tableName + '.' + fieldName);
if (timerEl != null){
//Make sure script does not break if field not present
var timerPause = timerEl.select('input[id*=paused]')[0];
var timerImg = timerEl.select('img[src*=images/timer_]')[0];
//Toggle the timer
if(timerPause.value == 'false'){
timerPause.value = 'true';
var timerIcon = $('link.' + g_form.tableName + '.' + fieldName);
timerIcon.removeClassName('icon-stop');
timerIcon.addClassName('icon-play');
//Change any title tags
timerIcon.setAttribute('data-original-title', 'Start Timer');
}
else{
timerPause.value = 'false';
var timerIcon = $('link.' + g_form.tableName + '.' + fieldName);
timerIcon.removeClassName('icon-play');
timerIcon.addClassName('icon-stop');
//Change any title tags
timerIcon.setAttribute('data-original-title', 'Pause Timer');
}
//Reset the timer to timerVal given
if(timerVal){
g_form.setValue(fieldName,timerVal);
}
}
}catch(e){}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2017 12:30 PM
I have used this on Task table and made it inherited. You can use on any table of your choice without any change in the code.
- function onLoad() {
- if(g_form.getElement('time_worked')){
- pauseTimer('time_worked');
- }
- }
- function pauseTimer(fieldName){
- try{
- //Get the necessary timer elements for fieldName given
- var timerEl = $('element.' + g_form.tableName + '.' + fieldName);
- if (timerEl != null){
- //Make sure script does not break if field not present
- var timerPause = timerEl.select('input[id*=paused]')[0];
- var timerImg = timerEl.select('img[src*=images/timer_]')[0];
- //Toggle the timer
- if(timerPause.value == 'false'){
- timerPause.value = 'true';
- if(timerImg){
- timerImg.src = 'images/timer_start.gifx';
- }
- else{
- //UI15 styling compatibility
- var timerIcon = $('link.' + g_form.tableName + '.' + fieldName);
- timerIcon.removeClassName('icon-stop');
- timerIcon.addClassName('icon-play');
- }
- }
- //Reset the timer to 0
- g_form.setValue(fieldName,'00:00:00');
- }
- }catch(e){}
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 08:20 AM
Hello,
this doesn't work like it should, time is not stopped each time we update form but it is just set to 00.00.00
It there any other solution?
Regards
Sniega
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2017 08:34 AM
Comment out line #31