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;
Hello,
It should be like this:
// 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;
that worked. thank you!
[ crawls back under desk - embarrassed didn't realize it should be == instead of = ]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are welcome! :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I try to run this it does not like line 6 with the "for" statement and I always get a null response
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christopher,
Can you help me where i need to place the SIL Script and how this script will be executed.
Any doc with the steps how to run this script.
Thanks in Advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.