Comments on: Pause or Toggle a Time Worked Field Timer https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/ ServiceNow Consulting Scripting Administration Development Thu, 07 Mar 2024 16:37:00 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Jacob https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8273 Tue, 02 May 2017 15:04:55 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8273 In reply to Mark Stanger.

I had the same issue as Marcel. The part that ‘zeros out the field when the form loads’ also now clears all time that had been saved. I’m on Istanbul.

By commenting that section, forms occasionally load with 1s already in the time worked field before the timer is paused, but the total time now continues to calculate properly

]]>
By: Mark Stanger https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8272 Mon, 27 Mar 2017 19:35:40 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8272 In reply to Jeremy Leslie.

Awesome! I’m glad you’ve got it working like you need!

]]>
By: Jeremy Leslie https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8271 Mon, 27 Mar 2017 19:30:27 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8271 In reply to Mark Stanger.

I see what had done wrong. I was using $j instead of $ when looking for link.table.element

Everything’s look good now! We’re in business using g_form.tableName as well.

]]>
By: Mark Stanger https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8270 Mon, 27 Mar 2017 16:54:22 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8270 In reply to Jeremy Leslie.

Thanks for sharing. Seems like there’s something odd going on with your system. This entire script works flawlessly in my Istanbul instance and I’ve never heard of ‘g_form.tableName’ not being supported in Istanbul (or anywhere else). I’d check to see if you’re getting some other error in your browser console. Even the image toggling should work without issue.

]]>
By: Jeremy Leslie https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8269 Mon, 27 Mar 2017 15:48:53 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8269 We recently upgraded our sub-production environments to Istanbul and it apparently broke this script. Turns out g_form.tableName is no longer supported, and using g_form.getTableName() fixed the issue.

That being said, there’s still a weird issue where the play/stop images won’t toggle. Still investigating that one. Just wanted to put this out there in case anyone has a similar issue.

]]>
By: Mark Stanger https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8268 Mon, 06 Mar 2017 19:44:06 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8268 In reply to Marcel.

The code you changed is designed to zero out the field when the form loads. It doesn’t zero out the time that has already been saved to the field though. It just sets it to zero when the field is paused.

As far as the background color goes, that is possible but it’s a bit of a hack…one that is likely to break during a future upgrade. Here’s the code; use at your own risk and make sure it’s on a list of things to verify (and potentially fix) during an upgrade.

$('element.incident.time_worked').select('.form-control').each(function(elmt) {
    elmt.style.backgroundColor = '#6EDB8F';
});
]]>
By: Marcel https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8267 Mon, 06 Mar 2017 19:00:06 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8267 In reply to Mark Stanger.

Thanks, I figured it out by removing some code to showing the following:

toggleTimer(‘time_worked’,’00:00:00′); and changed it to toggleTimer(‘time_worked’); and that seems to have worked.

One more, final silly question. The group requesting these changes now wants a color style applied to the timer field to make it stand out on the form. Applying style in the normal manner to a timer field doesn’t seem to do anything. So you know offhand if there is a way to apply a background color to the fields on the timer? I’m guessing that each one would need to be called in a script and a color defined?

]]>
By: Mark Stanger https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8266 Tue, 28 Feb 2017 01:17:43 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8266 In reply to Marcel.

That’s a bit harder to figure out without having access to your system. I can say that I’ve never seen that happen with this script before…at least in isolation. I’d start by attempting to reproduce in your dev or test instance in the same manner and then working from there. My guess would be some other client script is causing some sort of conflict or there’s some sort of user error involved.

]]>
By: Marcel https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8265 Mon, 27 Feb 2017 23:37:54 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8265 I’m having another odd issue that perhaps you can help with. I have the timer set up, it stays paused like it should with the client script, but now they’re reporting that when they enter time into the fields manually that on submit/save instead of incrementing the total time field it gets wiped out to 00:00:00 each time. I don’t recall seeing this issue during my testing but does seem to be the case currently, and no other changes I’m aware of in the instance have occurred.

]]>
By: Mark Stanger https://servicenowguru.com/system-ui/pausetoggle-time-worked-field/#comment-8264 Tue, 07 Feb 2017 20:20:06 +0000 https://servicenowguru.wpengine.com/?p=3384#comment-8264 In reply to Marcel.

The table name should be taken care of for you. Just replace anywhere that references ‘time_worked’ with the name of your field…’u_time_spent’.

]]>