Calculate combined duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2014 07:51 AM
Hi all,
A simple query for many..although it escapes me..(i have trawled the forums and unable to locate a defined answer).
Question:
I have 3 duration type fields (x, y and z) and wish to add these together to reveal a combined duration field (a). Sounds simple...although I cant for the life of me get this working. I
Summary: x + y + z = a
Tried client script (onChange)
var design = g_form.getValue('u_design');
var build = g_form.getValue('u_build');
var test = g_form.getValue('u_test');
var total = design + build + test;
g_form.setValue('u_total', total);
Any help, much appreciated...once done with that I then need to multiply that value by a 'b' to provide a cost..however one step at a time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2014 06:03 AM
Hi Pennie,
I can see where the problem is.
The duration is returned in a date format (specifically a UNIX timestamp) and this need to be converted to milliseconds before you can do your calculations.
The function you need is this:
dateNumericValue()
function calculateEstimatedCost(effort, rate){ gs.addInfoMessage('effort = ' +effort.dateNumericValue()); //should return a millisecond value var dayEffort = (effort.dateNumericValue()/(1000*60*60*24)); gs.addInfoMessage('dayEffort = ' +dayEffort); gs.addInfoMessage('day rate = ' +current.u_day_rate); var totalCost = rate * dayEffort; gs.addInfoMessage ('effort cost = ' +totalCost); current.u_estimated_cost = totalCost; }
I haven't been able to test it, but hopefully it's correct.
Let me know either way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2014 03:50 AM
Thats great thank you it worked!
Although, when I put the try and catch round it it gets a run time error of -
BR - Calculate cost effort - runtime error occurred: ReferenceError: "calculateEstimatedCost" is not defined
Which I can't see where the problem lies? Should I be worried about that? I don't see where its not defined?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2014 05:45 AM
Apologies for the delay.
Could you copy and paste your code fragment here... I'd like to have a look.
Thanks.