JJUPIN SIL sum of hours from linked issues

I want to sum the hours of linked issues into the parent\grouping issue.  It seems like this should be pretty simple in SIL using a for-loop and adding each subordinate value to the running total.

I'm trying to use SIL to do this, but keep getting "illegal workflow operation" error.

I have three custom fields:  "Rsch Hrs", "Prog Hrs", "Test Hrs".

Here is the script

//reset the parent values to zero

key.#{Rsch Hrs} = 0;

key.#{Prog Hrs} = 0;

key.#{Test Hrs} = 0;

// add each of the subordinate linked issue values

string [] linkedIssues =  linkedIssues(key);

for (string issue in linkedIssues) {

    key.#{Rsch Hrs} += %issue%.#{Rsch Hrs};

    key.#{Prog Hrs} += %issue%.#{Prog Hrs};

    key.#{Test Hrs} += %issue%.#{Test Hrs};

}

Any advice?

2 answers

1 accepted

This widget could not be displayed.

Hi Carl,

If some of the linked issues have empty values for one of the custom fields, the sum between empty value and a number or an interval can't be calculated.So, if the custom field has empty value, you have to set the values of the custom fields to 0. You can use the script below:

//reset the parent values to zero
 
%key%.#{Rsch Hrs} = 0;
 
%key%.#{Prog Hrs} = 0;
 
%key%.#{Test Hrs} = 0;
 
// add each of the subordinate linked issue values
 
string [] linkedIssues =  linkedIssues(key);
 
for (string issue in linkedIssues) {
	if(%issue%.#{Rsch Hrs} == ""){
        %issue%.#{Rsch Hrs} = 0;
    } 
    if(%issue%.#{Prog Hrs} == ""){
        %issue%.#{Prog Hrs} = 0;
    }
    if(%issue%.#{Test Hrs} ==  ""){
        %issue%.#{Test Hrs} = 0;
    }
 
    %key%.#{Rsch Hrs} += %issue%.#{Rsch Hrs};
 
    %key%.#{Prog Hrs} += %issue%.#{Prog Hrs};
 
    %key%.#{Test Hrs} += %issue%.#{Test Hrs};
 
}

 

Best regards,

Raluca

Thanks. Definitely makes the code more robust.

This widget could not be displayed.

Hi Carl,

You should also use substitution for key. You code should look like this:

//reset the parent values to zero
%key%.#{Rsch Hrs} = 0;

%key%.#{Prog Hrs} = 0;

%key%.#{Test Hrs} = 0;

// add each of the subordinate linked issue values

string [] linkedIssues = linkedIssues(key);

for (string issue in linkedIssues) {

%key%.#{Rsch Hrs} += %issue%.#{Rsch Hrs};

%key%.#{Prog Hrs} += %issue%.#{Prog Hrs};

%key%.#{Test Hrs} += %issue%.#{Test Hrs};

 

Hope this helps,
Alexandra 

Thanks. Replacing "key" with "%key%" made it work. This will be a big help

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

81 views 4 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you