Calculating Time for All Tasks in one Change Ticket

Hi guys,

I have a custom field "tasktime" in all task categories where the users describe the time they've spend to resolve a current task.
I need to calculate the overall time of all tasks in one change ticket and display the result in the Change Record.

For example: I have 1 change ticket. In that change ticket there are 4 different tasks. Each task took 2 hours for resolution, so in each record we have the value "2". Now i have to see the overall result of "8" in a new custom field in the Change ticket.

Any ideas how can I achieve that ?

Many thanks in advance.

  • Generally speaking, are you running SM with or without Process Designer? Which version you use?

    Anyway, I'll throw my input in. I took a dive into JS callback functions, which I've not used. So please bare me, if code is not as optimal as it could. A prerequisite is that you have a Underscore JS library in your SM. I assume it was shipped with SM 9.40 or so.

    SM 9.41 contains a JS library "AgreementUtil" which contains some examples how to create "tight" code. At least what comes to traditional file selection and loop structures, that require more lines when coding in an "old-school" way. I used the functions in the library to solve your problem.

    This is just an example and you need to assign it to your Format Control or Ruleset in your Request workflow, but I assume you are capable to do that by yourself. Also, the code is made for Requests and Request Tasks (our organization does not use Change Tasks...), but the structure (main ticket, child tickets) is similar to Change/Change Tasks.


    var id = "RF10079";
    print( getSumOfTaskField( id, "sysmodcount" ) );
    function getSumOfTaskField( parent_id, field ) {
        var $ = lib.c.$;
        var _ = lib.Underscore.require();
        var dutyhours = 0;
        $("requestTask", SCFILE_READONLY).select("parent.request=\""   parent_id    "\"").iterate(
            function(record) {    
                if (_.isNumber( record[field]) )  {
                    dutyhours  =  system.functions.nullsub( record[field], 0);
                } else {
                    dutyhours  = 0;
        return dutyhours;