Create scorecards Programatically in PPS


Hello,

After working with PPS I came across a Project which requires Building of Scorecards Programatically and assign KPIs to it

the below Sample can show you how to create scorecards inside PPS

protected void CreateScoreCard()
{
Guid AGuid;
// create a new scorecard instance
AScoreCard_wows = Scorecard.CreateNew();
// Setting the name property;
BpmPropertyText NameProperty = new BpmPropertyText();
NameProperty.Text = "The ScoreCard";
AScoreCard_wows.Name = NameProperty;
AScoreCard_wows.Description.Text = "This Scorecard was created by code";
// Setting the owner property
AScoreCard_wows.Owner.Login = @"Server\Administrator";
// Configuring the scorecard view
ConfiguredView ACofiguredView = new ConfiguredView();
GridViewDefinition ParentChildDefinition = new GridViewDefinition();
GridHeaderItem ParentX = new GridHeaderItem();
AGuid = Guid.NewGuid();
ParentX.Guid = AGuid;
ParentX.DefinitionGuid = AGuid;
ParentX.DisplayText = "ParentX";
ParentX.DimensionName = "Scorecard__";
ParentX.DimensionValue = "cd30315e-bd40-4977-b21b-cbb47cc83494"; // Guid of KPI
ParentX.HeaderType = ScorecardNodeTypes.Kpi;
ParentX.Depth = 1;
ParentChildDefinition.RootRowHeader.Children.Add(ParentX);
GridHeaderItem ChildX = new GridHeaderItem();
AGuid = Guid.NewGuid();
ChildX.Guid = AGuid;
ChildX.DefinitionGuid = AGuid;
ChildX.DisplayText = "ChildX";
ChildX.DimensionName = "Scorecard__";
ChildX.DimensionValue = "e9ec1e6b-8c7e-4f7d-b87d-28cad4b29d7f"; // Guid of KPI
ChildX.LinkedKpiId = new Guid("e9ec1e6b-8c7e-4f7d-b87d-28cad4b29d7f");
ChildX.HeaderType = ScorecardNodeTypes.Kpi;
ChildX.Depth = 2;
ParentX.Children.Add(ChildX);
GridHeaderItem ChildY = new GridHeaderItem();
AGuid = Guid.NewGuid();
ChildY.Guid = AGuid;
ChildY.DefinitionGuid = AGuid;
ChildY.DisplayText = "ChildY";
ChildY.DimensionName = "Scorecard__";
ChildY.DimensionValue = "8878d533-b7b7-40f7-8772-4da81c54c85b"; // Guid of KPI
ChildY.LinkedKpiId = new Guid("8878d533-b7b7-40f7-8772-4da81c54c85b");
ChildY.HeaderType = ScorecardNodeTypes.Kpi;
ChildY.Depth = 2;
ParentX.Children.Add(ChildY);
GridHeaderItem ActualColumn = new GridHeaderItem();
AGuid = Guid.NewGuid();
ActualColumn.Guid = AGuid;
ActualColumn.DefinitionGuid = AGuid;
ActualColumn.DisplayText = "Actual";
ActualColumn.DimensionName = "Scorecard_Measures__";
ActualColumn.DimensionValue = "Actual"; // Guid of KPI
ActualColumn.HeaderType = ScorecardNodeTypes.KpiActual;
ActualColumn.Depth = 1;
GridTargetSettings ActualColumnTargetSettings = new GridTargetSettings();
ActualColumnTargetSettings.ShowImage = true;
ActualColumnTargetSettings.ShowScore = true;
ActualColumnTargetSettings.RollupType = RollupTypes.AverageWeighted;
ActualColumnTargetSettings.ScoreType = ScoreTypes.Normalized;
ActualColumn.TargetSettings = ActualColumnTargetSettings;
ParentChildDefinition.RootColumnHeader.Children.Add(ActualColumn);
GridHeaderItem TargetColumn = new GridHeaderItem();
AGuid = Guid.NewGuid();
TargetColumn.Guid = AGuid;
TargetColumn.DefinitionGuid = AGuid;
TargetColumn.DisplayText = "Target";
TargetColumn.DimensionName = "Scorecard_Measures__";
TargetColumn.DimensionValue = "Target"; // Guid of KPI
TargetColumn.HeaderType = ScorecardNodeTypes.KpiTarget;

TargetColumn.Depth = 1;
GridTargetSettings TargetColumnTargetSettings = new GridTargetSettings();
TargetColumnTargetSettings.ShowImage = true;
TargetColumnTargetSettings.ShowScore = true;
TargetColumnTargetSettings.RollupType = RollupTypes.AverageWeighted;
TargetColumnTargetSettings.ScoreType = ScoreTypes.Raw;
TargetColumn.TargetSettings = TargetColumnTargetSettings;
ParentChildDefinition.RootColumnHeader.Children.Add(TargetColumn);
ACofiguredView.GridViewDefinition = ParentChildDefinition;
AScoreCard_wows.ConfiguredViews.Add(ACofiguredView);
// Publishing the ScoreCard
Publisher.CreateScorecard(AScoreCard_wows);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s