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