Oliver.Meyer wrote:Now I have to come up with another solution to my problem of sorting the tasks according to the requirement priorities....
And perhaps I have one, by setting a function in the workflow table of your task.
The corresponding chapter in the Polarion help is here
(search for the heading "Workflow Functions (Work Items)"
My solution consists of a javscript file that is executed in every work flow action of the task.
Here it is, I have not tested it but I have written it based on another JS file I executed that way,
so I guess it should work. COpy the following code and save it in a file that we call calcAveragePriority.js
Code: Select all
var workitem = workflowContext.getTarget(); // here we get the task
var linked_items = workitem.getLinkedWorkItems(); // To be honest I do not know in which direction the linked items (parent of child only) are fetched here, you have to test it please
var requirementsPrioritySum = 0;
var linkedRequirementsCount = 0;
var averagePriority = 0;
for (i = 0; i < linked_items.length; i++)
/* The type */
if(linked_items[i].getType().id == "requirement")
dueDate_of_Parent = linked_items[i].getDueDate();
requirementsPrioritySum = requirementsPrioritySum + linked_items[i].getPriority():
} /* end of if */
} /* end of for loop */
/* calculating the average priority of the requirements that is then inserted in the priority field of the parent task */
averagePriority = (requirementsPrioritySum / linkedRequirementsCount);
workitem.setValue("priority", average );
Or does setting the value work that way? I am not sure anymore
workitem.setPriority( average )
Note that this script does only run in the context of work item status transitions in Polarion.
You have to enter the workflow menu in the administration section of your Polarion project.
Pick any work item type and go to the "Actions" section of the workflow page of the item.
There you can enable a script function option. This will trigger a script every time the Action is executed.
Enter then as Parameters (the text in CAPITAL LETTERS) are the columns.
NAME | VALUE | ACTIONS
script | calcAveragePriority.js
NOTE: calcAveragePriority.js must be stored in the scripts folder of the Polarion installation (to C:\Polarion\scripts or the equivalent folder in Linux: /opt/polarion/scripts). Ask you System Administrator for getting access to these folders.
Basically, you can apply all methods on work items that are listed here (this is usually the reference for Velocity scripts):https://almdemo.polarion.com/polarion/s ... kItem.html