I'm using a calculated field to present the percent complete of a task - percent is based on the number of sub-tasks in the DONE status.
Using a SIL script I'm able to retrieve the # of sub-tasks of a parent task, but now I need to determine which of those subtasks have a status of DONE. I tried JQL - it just returned every sub-task of every parent task in the entire project that was in the DONE status; I don't think you can use a variable in JQL query, so only a static search would work when I'd tried filtering THIS SPECIFIC TASK'S sub-tasks.
I've given up on trying to use JQL filters in my SIL script, and have the script below. But I keep getting "lexical" errors, when trying to save it. Can someone please review, and let me know where I've gone off track? I've commented out the test lines I've attempted, whether they've failed or succeeded, just to illustrate what I've tried thus far.
Thank you,
Chris
--------------
// script to calculate percent of Parent Task complete based on # of completed subtasks.
//
number subtaskCount = size(subtasks(key)); // number of subtasks of parent issue
string [] allSubs = subtasks(key); // string with keys of all parent's subtasks ? I think?
number doneCount = 0;
for (string eachTask in allSubs){
if (status = 'DONE') {
// if (%eachTask%.status = 'DONE'){
// if (%eachTask%.status = "DONE"){
doneCount = doneCount + 1;
}
}
number prctDone = ((doneCount / subtaskCount) * 100);
//return "num of subtasks " + subtaskCount;
//return "num of subtasks in DONE " + doneCount; // IF this works, it ALWAYS returns 0
return "Percent complete: " + prctDone;