Use/Calculate PERT in JIRA?

Hello everybody,

As the title said, I want to use/calculate PERT for all issues, included subtasks

I have created some custom fields:

  • number fields: mintime, maxtime, normaltime, perttime
  • scripted field: pertcalc

here is the inline script for pertcalc:

import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.ModifiedValue;
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder;
import com.atlassian.jira.util.ImportUtils;
import com.atlassian.jira.config.SubTaskManager;
 
def cfManager = ComponentAccessor.getCustomFieldManager();
def pertsum = 0;
pertsum += calc_pert(issue);
 
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
Collection subTasks = issue.getSubTaskObjects();
 
if (subTaskManager.subTasksEnabled && !subTasks.empty) {
  subTasks.each {
    pertsum += calc_pert(it);
  }
}
def pert = cfManager.getCustomFieldObjectByName("perttime");
pert.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(pert), pertsum), new DefaultIssueChangeHolder());
   return pertsum.toString();
 
 
double calc_pert(Issue issue)
	{
    double p = 0;
	def min=issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("mintime"));
       def mindouble = (double) min;
	def mayx=issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("maxtime"));
       def maxdouble = (double) max;	
	def nnormal=issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("normaltime"));
       def normaldouble = (double) normal;
    p = (mindouble +  maxdouble + 4*normaldouble)/6;
    return p;
	}

 

The problem is the number field "perttime" does not get any result

so I guess I should have made some mistakes, maybe at those with "getCustomFieldValue" and "getCustomFieldObjectByName"

 

Hopefully someone may help me solving this

2 answers

This widget could not be displayed.

Start with debugging what the fields are returning - your code assumes they are numbers, and that they are all filled in for every issue you are examining - are both of those actually true?

Did you mean that I should try with script console?

if yes, i got the error:

No such property: issue for class: Script71

groovy.lang.MissingPropertyException: No such property: issue for class: Script71 at Script71.run(Script71.groovy:12)

If you are going to try this in the script console, then you will need to add code to the top of it to say which issue to work on.

but is it the right syntax to read the value of the custom fields?

for example:

def min=issue.getCustomFieldValue(cfManager.getCustomFieldObjectByName("mintime"));

if i remove those code with getCustomFieldValue, then the number field perttime receive "0" from scripted field "pertcalc"

so I guess everything else works correctly except those with getCustomFieldValue

That looks right to me.

This widget could not be displayed.

Hello! You can also use Jira Cloud addon "PERT calculator", it is very simple and fast. 

You can enter 3 values and get deviation and pert values. Please, check the images!

 

You can try it for free for 30 days here: https://marketplace.atlassian.com/plugins/pert-calculator/cloud/overview.

pert 2.PNGpert1.PNG

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
Published Apr 22, 2018 in Jira Software

How-to setup a secured Jira Software 7.9.0 on Ubuntu 16.04.4 in less than 30 minutes

...PermissionsStartOnly=true User=www-data Group=www-data ExecStart=/opt/jira/bin/startup.sh ExecStop=/opt/jira/bin/shutdown.sh TimeoutStartSec=120 TimeoutStopSec=600 PrivateTmp=true [Install] WantedBy...

1,090 views 6 12
Read article

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