> ## 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.

# Derive Schedule from Polarion Plans

> Configure Nextedy GANTT to derive work item schedules from their assignment to Polarion Plans, so that unplanned items inherit the plan's start and end dates automatically.

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>;
};

## When to Use This Approach

Use plan-derived scheduling when work items do not have their own start/end date fields populated but are assigned to Polarion Plans (iterations, releases) that have defined date ranges. This is common in agile workflows where sprints and iterations define the schedule.

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/XoCXinV6eKUe5dKK/gantt/images/48001142527/1.png?fit=max&auto=format&n=XoCXinV6eKUe5dKK&q=85&s=07a1a2ebf3d1f24dee9418a63890cb51" alt="Gantt chart showing a user story whose schedule is derived from its assignment to a Polarion Plan instead of from date fields" width="1094" height="192" data-path="gantt/images/48001142527/1.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/XoCXinV6eKUe5dKK/gantt/images/48001142527/2.png?fit=max&auto=format&n=XoCXinV6eKUe5dKK&q=85&s=62149baa5dde89be11a5ba22138ff4f3" alt="User story PCP-43 assigned to Iteration 34, with its Gantt schedule taken from that sprint assignment" width="1356" height="368" data-path="gantt/images/48001142527/2.png" />
</Frame>

<Steps>
  <Step title="Add the Item Script">
    Navigate to **Widget Properties > Advanced > Item Script** and add one of the following scripts depending on your scenario.

    ### Option A: Derive Schedule for All Unplanned Items

    Use the built-in utility method to automatically assign plan dates to unplanned work items:

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

    Replace `"iteration"` with the plan template ID that matches your project (e.g., `"release"`, `"sprint"`).

    <Frame>
      <img src="https://mintcdn.com/none-17b4493f/DW7SPQWol8VdzZS9/gantt/images/48001142527/3.png?fit=max&auto=format&n=DW7SPQWol8VdzZS9&q=85&s=93a1fa684c4cddee967357f4c9801e71" alt="Unplanned Work Package 'The Primary Flight Displays' shown on the Gantt chart before its schedule is derived" width="2610" height="542" data-path="gantt/images/48001142527/3.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/none-17b4493f/DW7SPQWol8VdzZS9/gantt/images/48001142527/4.png?fit=max&auto=format&n=DW7SPQWol8VdzZS9&q=85&s=8b5731b6f20ac3989763e55e1c32bc96" alt="The Work Package planned in Iteration 39, which ends on 10.10.2023" width="1930" height="452" data-path="gantt/images/48001142527/4.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/none-17b4493f/DW7SPQWol8VdzZS9/gantt/images/48001142527/5.png?fit=max&auto=format&n=DW7SPQWol8VdzZS9&q=85&s=f20058adc5925afdc9de49394eba386c" alt="Polarion Plan view confirming Iteration 39 and its end date used as the source for the derived schedule" width="1242" height="390" data-path="gantt/images/48001142527/5.png" />
    </Frame>

    ### Option B: Derive Schedule for a Specific Plan Type

    For more control, iterate through the work item's plan assignments and match a specific template:

    ```javascript theme={null}
    var plans = wi.getPlannedIn().iterator();
    while (plans.hasNext()) {
      var plan = plans.next();
      if (plan.getTemplate().getId() === "Iteration") {
        task.start_date = util.getDate(plan, "startDate");
        task.end_date = util.getDate(plan, "dueDate");
        task.duration = null;
        task.readonly = true;
        task.unplanned = false;
      }
    }
    ```

    | Property                 | Effect                                         |
    | ------------------------ | ---------------------------------------------- |
    | `task.start_date`        | Sets the task start from the plan's start date |
    | `task.end_date`          | Sets the task end from the plan's due date     |
    | `task.duration = null`   | Clears duration so it is computed from dates   |
    | `task.readonly = true`   | Prevents manual editing of derived dates       |
    | `task.unplanned = false` | Marks the item as scheduled on the Gantt chart |

    <Warning title="Null check is required">
      Always wrap your Item Script with `if (wi != null)` to prevent errors when the script processes synthetic or missing work items. Without this check, the script may fail silently.
    </Warning>

    <Warning title="Use the property-assignment form for dates">
      Set the derived dates with `task.start_date` and `task.end_date` (property assignment, as shown above) -- this is the documented form (see the [Item Script API](/gantt/reference/api/item-script-api)). Do **not** assign to `task.setStart_date` / `task.setEnd_date`: those are setter *methods*, not assignment targets, so assigning a value to them does not set the date. For the Polarion 2304+ scripting changes (getter methods and `typeof` checks), see [Migrate Scripts for Polarion 2304+](/gantt/guides/scripting/script-migration-2304).
    </Warning>
  </Step>

  <Step title="Configure the Plans Gantt View (Optional)">
    If you want to display both plans and work items together on a single Gantt chart, use the Plans Gantt widget:

    1. Set **Widget Properties > Show Plan Work Item > Enable Show Items** to **true**.
    2. Configure the **Load Children** depth to control how many levels of sub-plans and work items are displayed.
    3. Set the child link role to load work items under their parent plans.

    <Tip title="Combine with the Roadmap view">
      For portfolio-level visibility, configure the Plans Gantt with Release as the top-level plan template, Iteration as the second level, and work items as the third level. Set **Load Children** to `3` to display the full hierarchy.
    </Tip>
  </Step>

  <Step title="Save and Reload">
    Save the widget properties and reload the page. The Gantt chart recalculates work item positions based on their plan assignments.
  </Step>
</Steps>

## Verification

You should now see:

* Previously unplanned work items now positioned on the Gantt chart at the dates of their assigned plans
* Derived items marked as read-only (not draggable) if you set `task.readonly = true`
* Plan date ranges reflected accurately on the work item task bars

<Frame>
  <img src="https://mintcdn.com/none-17b4493f/DW7SPQWol8VdzZS9/gantt/images/48001142527/6.png?fit=max&auto=format&n=DW7SPQWol8VdzZS9&q=85&s=2437217dc13aa00f84f82856a9d316ec" alt="The previously unplanned Work Package now scheduled on the Gantt chart with dates inherited from its assigned Iteration 39 plan" width="3074" height="350" data-path="gantt/images/48001142527/6.png" />
</Frame>

## See Also

* [Derive Parent Schedule from Children](/gantt/guides/scheduling/parent-derived-schedule)
* [Show Plans and Work Items Together](/gantt/guides/plans/plans-and-work-items)
* [Write Item Scripts](/gantt/guides/scripting/item-script-basics)
* [Migrate Scripts for Polarion 2304+](/gantt/guides/scripting/script-migration-2304)
* [Sync Work Item Dates to Plans](/gantt/guides/plans/sync-to-plans)

<LastReviewed date="2026-06-24" />
