Sometimes you need to derive a schedule of the Work Item not from fields such as gantt-start and gantt-duration, but you may want to load it from an assignment of the work item to the Polarion Plan.
Imagine there is a user story
and you want this schedule of the user story PCP-43 being derived from the assignment to a sprint (AKA Iteration). As this story is assigned to Iteration 34.
You can configure this with the following Widget Property > Advanced > Item Script
var plans = wi.getPlannedIn().iterator(); while(plans.hasNext()){ var plan = plans.next(); if(plan.getTemplate().getId()==="Iteration"){ task.setStart_date=util.getDate(plan, "startDate"); task.setEnd_date=util.getDate(plan, "dueDate"); task.duration=null; task.readonly=true; task.unplanned=false; } }
In case you have some unplanned Work Items, you can use the utility method below in the Item Script to derive the Work Items Schedule from the Plan:
task.deriveScheduleFromPlans(IWorkItem item, String templateId)
Example:
There is an unplanned Work Package "The Primary Flight Displays":
It is planned in Iteration 39, which ends 10.10.2023:
Now we are going to use the method mentioned above to make it derive its schedule from the Plan. To do so, add the following snippet to the Item Script section:
if(task.unplanned){ task.deriveScheduleFromPlans(wi,"iteration"); }
As a result, the Work Package gets the schedule from the Plan.
Note:
If you encounter an error while executing the script, it may be due to the script attempting to process a non-existent work item. To resolve this issue, add an additional condition line to the Item Script to ensure the work item exists before running the script:
if (wi !=null){ if(task.unplanned){ task.deriveScheduleFromPlans(wi,"iteration"); } }
In case of any questions please contact support@nextedy.com
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article