Set Time Worked Timer Minutes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2016 01:10 AM
Hi Experts
I have a script which is rounding the timer in the timer Worked Field of Incident: if the minutes are less than 30 will round them to 30 and more than 30 will round them to 60 minutes.
it was working till we upgrade our system to Helsinki.
I am using this script:
************************************************************************
var fieldName = 'incident.time_worked';
//function checkTimeWorked(fieldName) {
var timeObjectName = fieldName;
var timeObjectHidden = gel(timeObjectName);
var timeObjectParent;
var timeObjectFields;
if(timeObjectHidden != null) {
if(timeObjectHidden.type != null) {
if (timeObjectHidden.type == "hidden") {
timeObjectParent = timeObjectHidden.parentNode;
timeObjectFields = timeObjectParent.getElementsByTagName("input");
var timerTestString = "paused";
//loop through input objects looking for the pause timer object
for(var elIt=0;elIt<timeObjectFields.length;elIt++) {
if (timeObjectFields[elIt].id.match(timerTestString)) {
var tof = timeObjectFields[elIt].id;
var tmr_base = tof.substring(0, tof.length-(timerTestString.length+1));
var tmr_hour = tmr_base + "_hour";
var tmr_min = tmr_base + "_min";
var tmr_sec = tmr_base + "_sec";
var tmr_image = tmr_base + "_img";
var hour = g_form.getValue(tmr_hour);
var min = g_form.getValue(tmr_min);
var sec = g_form.getValue(tmr_sec);
alert(min);
if(min > 0 && min < 30 ) {
g_form.setValue(tmr_min, 30);
g_form.submit();
} else if (min > 30 && min < 60) {
g_form.setValue(tmr_min, 60);
}
*************************************************************************************+
I can see the minutes rounding on the timer but when I click submit it wont update it.
somehow the set Value is not working anymore.
does someone has an idea?
or maybe another way to set minutes.
thanks
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 12:48 AM
Hi ebeylouny,
Could you please post the solution here. Also on which table have you run this script. Seems like this is on change client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 03:02 AM
it is onChange Client script for Incident or Problem or whereever you Need it for Time Worked field.
Cheers
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 03:42 AM
Thanks for the quick reply.
"I can see the minutes rounding on the timer but when I click submit it wont update it"
Were you able to fix this issue?If yes, could you please post the solution here.
Thanks In advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2018 12:13 AM
Found the solution for this:
Write a before insert business rule on time worked table:
var tms = current.time_worked.dateNumericValue(); //get timeworked in miliseconds
var u = Math.ceil(tms/900000)*900000; //round to nearest 15 minute increment
current.time_worked.setDateNumericValue(u);
It should set the time worked field in time worked table.