> ## Documentation Index
> Fetch the complete documentation index at: https://learn.nextedy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Compute Plan Progress

> Calculate and display plan completion progress in the Nextedy GANTT Plans Gantt view using a server-side item script that counts resolved versus total work items.

export const LastReviewed = ({date}) => {
  if (!date) return null;
  const formatted = new Date(`${date}T00:00:00Z`).toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC"
  });
  return <p className="mt-10 text-sm text-gray-400 dark:text-zinc-500 not-prose">
      Last reviewed on {formatted}
    </p>;
};

## How Plan Progress Works

In the Plans Gantt, plan bars do not have a built-in progress calculation. You use an **Item Script** to query work items assigned to each plan, compute a completion ratio, and display it on the Gantt chart.

The script runs server-side for each plan item, calculating progress as the ratio of resolved work items to total work items in the plan.

<Steps>
  <Step title="Add the Gantt Config Script">
    Open the Plans Gantt widget parameters and navigate to **Advanced > Gantt Config Script**. Add the following script to display progress as right-side text on each plan bar:

    ```javascript theme={null}
    gantt.templates.rightside_text = function(start, end, task) {
        return (task.progress > 0
            ? "Progress: <b>" + Math.round(task.progress * 100) + " % (" + task.fields.progressString + ")</b>"
            : "");
    };
    ```

    This script renders progress text to the right of each plan bar, showing both the percentage and the resolved/total count.
  </Step>

  <Step title="Add the Item Script">
    Navigate to **Advanced > Item Script** and add the server-side computation:

    ```javascript theme={null}
    var allitems = trackerService.queryWorkItems(
        "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ")", "id"
    ).size();
    var resolveditems = trackerService.queryWorkItems(
        "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ") AND HAS_VALUE:resolution", "id"
    ).size();
    if (allitems > 0) {
        task.progress = resolveditems / allitems;
    } else {
        task.progress = 0;
    }
    task.getFields().put("progressString", resolveditems + " / " + allitems + " done");
    ```

    This script:

    1. Queries all work items assigned to the current plan
    2. Queries work items with a resolution (resolved items)
    3. Computes progress as the ratio of resolved to total
    4. Stores a human-readable string for display

    <Frame>
      <img src="https://mintcdn.com/none-17b4493f/umKaPvHwUHw-ZQFM/gantt/diagrams/guides/plans/plan-progress/diagram-1.svg?fit=max&auto=format&n=umKaPvHwUHw-ZQFM&q=85&s=8baf3b80dd4200463dda656ddbc4ab26" alt="diagram" style={{ maxWidth: "920px", width: "100%" }} width="920" height="70" data-path="gantt/diagrams/guides/plans/plan-progress/diagram-1.svg" />
    </Frame>
  </Step>

  <Step title="Derive Work Item Schedule from Plans">
    If work items under your plans are unplanned (no start/end dates), you can derive their schedule from the plan assignment. Add this to the **Item Script** section of your Work Items configuration:

    ```javascript theme={null}
    if (typeof wi !== 'undefined') {
        if (task.unplanned) {
            task.deriveScheduleFromPlans(wi, "iteration");
        }
    }
    ```

    <Warning title="Null check required">
      Always wrap work item script logic with a `typeof wi !== 'undefined'` check. If the script runs on a plan item that has no backing work item, `wi` is undefined and the script throws an error. See [Migrate Scripts for Polarion 2304+](/gantt/guides/scripting/script-migration-2304) for details.
    </Warning>

    <Tip title="Progress syncs on schedule changes only">
      The progress value is computed each time the Gantt loads or refreshes data. Editing work item resolution status outside the Gantt requires a Gantt refresh to update the progress display.
    </Tip>
  </Step>
</Steps>

## Customizing the Progress Query

You can adjust the progress calculation by modifying the Lucene query in the item script. For example, to count only items with status "done" instead of any resolution:

```javascript theme={null}
var resolveditems = trackerService.queryWorkItems(
    "PLAN:(" + plan.getProjectId() + "/" + plan.getId() + ") AND status:done", "id"
).size();
```

## Verification

You should now see progress percentages displayed to the right of each plan bar in the Plans Gantt, showing text like "Progress: **75% (3 / 4 done)**". Plans with no assigned work items show no progress text.

## See Also

* [Show Plans and Work Items Together](/gantt/guides/plans/plans-and-work-items)
* [Track and Calculate Progress](/gantt/guides/editing/progress-tracking)
* [Calculate Progress with Scripts](/gantt/guides/scripting/progress-calculation-scripts)
* [Write Item Scripts](/gantt/guides/scripting/item-script-basics)
* [Derive Schedule from Polarion Plans](/gantt/guides/scheduling/plan-derived-schedule)

<LastReviewed date="2026-07-07" />
