Highlighted
Visitor.
190 views

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.

0 Likes
2 Replies
Highlighted
Visitor.

Re: Calculating Time for All Tasks in one Change Ticket

Any suggestions, please?

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Calculating Time for All Tasks in one Change Ticket

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;
}

 

 

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.