Creating a Milestone Report

This example creates a milestone overview report which shows all assigned documents of a milestone together with the document state and document version.

1. Create a Report with a Stages Data Source and a Data Set

2. Create the following Data Set result columns

NameType
DocumentNameString
StateString
VersionString
milestone URLString
processString

3. Copy the Data Set script from the example into your Data Set.

Example

function getParent(myelement) {
 var process = "";
 do {
 var parent =

 myelement.getEntities("hierarchy::HIERARCHIC@LOCAL,targetrole=parent");
 if (parent[0].getProperty("IndexMode") == 1) {
 return (process);
 }
 process = parent[0];
 myelement = parent[0];
 } while (parent[0].getProperty("IndexMode") != 1);
 return (null);
}
function Dump(artifact, milestone) {
 var reduced_view = "";
 var milestone_name = milestone.getProperty("DisplayName");
 var artifact_name = artifact.getProperty("DisplayName")
 var artifacts_instances =
 artifact.getEntities("containsInstance@SYSTEM");
 var artifact_id = artifact.getProperty("Id");
 for each (artifacts_instance in artifacts_instances) {
 var artifacts_instance_id = artifacts_instance.getProperty("Id");
 dataset.setColumnValue("DocumentName",
 "<a title=\""+artifact_name+"\" href=\"/pkit/process/viewElement.do?
id=" +
 artifact_id+"&type=Artifact\">" +
 artifacts_instance.getProperty("LogicalName")+"</a>");
 dataset.setColumnValue("milestone URL",
 "<a href=\"/pkit/process/viewElement.do?id=" +
 milestone.getProperty("Id")+"&type=phase\">" +
 milestone.getProperty("DisplayName")+"</a>");

 dataset.setColumnValue("Version",
 artifacts_instance.getProperty("revisionIdentifier"));
 dataset.setColumnValue("State",
 artifacts_instance.getProperty("state"));
 var parent = getParent(artifact);
 if (parent)
 dataset.setColumnValue("process",
 "<a href=\"/pkit/process/viewElement.do?id=" +
 parent.getProperty("Id")+"&type=Artifact\">" +
 parent.getProperty("DisplayName")+"</a>");

 dataset.storeResultRow();
 }
}
var milestones = pkit.getCurrentProject().
 getEntities("containsProcess@SYSTEM")[0].
 getEntities("containsPhase@SYSTEM");
for each (milestone in milestones) {
 if (milestone.getProperty("SubType") == "milestone") {
 var artifacts = milestone.getEntities("required");
 for each (artifact in artifacts) {
 Dump(artifact, milestone);
 }
 }
}