API Example: Compute Plan progress for Plans GANTT on the server using API

Modified on Mon, 13 Jan, 2020 at 12:50 PM

Imagine you want to calculate the progress of the Epic as % of resolved vs all child stories.


- Advanced > Gantt Config Script
gantt.templates.rightside_text = function(start, end, task){
return (task.progress > 0 ?"Progress: <b>"+Math.round(task.progress * 100)+" % ("+task.fields.progressString+")</b>":"");
};

- Advanced > Item Script:
var allitems = trackerService.queryWorkItems("PLAN:("+plan.getProjectId()+"/"+plan.getId()+")","id").size();
var openitems = trackerService.queryWorkItems("PLAN:("+plan.getProjectId()+"/"+plan.getId()+" ) AND HAS_VALUE:resolution","id").size();
if(allitems>0){
task.progress = openitems / allitems;
}else{
    task.progress = 0;
}
task.getFields().put("progressString", openitems +" / " + allitems +" done");

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article