locked
KPI creation problem RRS feed

  • Question

  • Hello,

     


    We need to create KPIs programmatically in standard list of PerformancePoint elements (http://<server name>/Lists/PerformancePoint Content/). To do that we created WebService in the context of SharePoint 2010 (you can find its code below). While user "SharePoint\system" has full access to list and site w hen service calls method “CreateKpi” the following access error occurs:

     

    “User "SharePoint\system" tried to save element at following location:

    http://<server name>/Lists/PerformancePoint Content/

    Verify that this location exists and user has permission “Addition of elements”

     

    Exception details :

    Microsoft.PerformancePoint.Scorecards.BpmException: Failed to create the item ''.

       at Microsoft.PerformancePoint.Scorecards.Store.Dao.SPListItemDao.Create(ISPFcoCache cache, Guid webSiteID, String listUrl, FirstClassElement element)

       at Microsoft.PerformancePoint.Scorecards.Store.SPDataStore.SPDaoCreate(String listUrl, FirstClassElement element, String spObjectTypeId)”

     

    What´s going wrong?

     

    Thanks,

    Konstantin

     

    Our WebService code

     

    [WebService (Namespace = "http://tempuri.org/ " )]

    [WebServiceBinding (ConformsTo = WsiProfiles .BasicProfile1_1)]

    [ScriptService ]

    public class PPService : System.Web.Services.WebService

    {

        public PPService()

        {

            //Uncomment the following line if using designed components

            //InitializeComponent();

        }

       [WebMethod ]

        public string CreateKPIData()

        {

            StringBuilder res = new StringBuilder ("" );

            try

            {

                BpmPropertyText txt = new BpmPropertyText ();

                txt.Description = "My KPI" ;

                txt.DisplayName = "Test" ;

                Microsoft.PerformancePoint.Scorecards.Kpi kpi = Microsoft.PerformancePoint.Scorecards.Kpi .CreateNew();

                kpi.Name = txt;

                Microsoft.PerformancePoint.Scorecards.Store.SPDataStore spDataStore =Microsoft.PerformancePoint.Scorecards.Store.SPDataStore .GlobalDataStore;

               

                spDataStore.CreateKpi("/Lists/PerformancePoint Content/" , kpi);

            }

            catch (Exception ex)

            {

                res.Append(ex.Message);

            }

            return res . ToString ();

        }

    }

    Thursday, February 18, 2010 2:32 PM

Answers

  • Hi Konstantin,
    In your exception handler, try looking at "ex.InnerException" to see if you get some more details as to what is failing.

    My guess: there is some code that checks to see if the KPI is valid.  One of the checks it does is to make sure an "Actual" has been defined, and since you did not define one it is probably throwing an error.

    Here is an example of how to create "fixed value" actuals and targets:

                /*
                 * using Microsoft.PerformancePoint.Scorecards;
                 * using Microsoft.PerformancePoint.Scorecards.Store;
                 * using Microsoft.PerformancePoint.Scorecards.Indicators;
                 */
    
    
                Kpi newKpi = Kpi.CreateNew();
                newKpi.Name.Text = "Test KPI";
                newKpi.Description.Text = "Created via SDK";
    
                // Fixed value actual
                newKpi.Actual.DataSourceLocation = new RepositoryLocation(Constants.FixedValuesDataSourceLocationKey);
                newKpi.Actual.ModelCurrent = 80;    // this sets the value for the actual
    
                // Fixed value target
                Target target1 = new Target();
                target1.Guid = Guid.NewGuid();
                target1.Name.Text = "Target";
                target1.DataSourceLocation = newKpi.Actual.DataSourceLocation;
                target1.ModelCurrent = 100; // this sets the value for the target
                target1.IndicatorLocation =
                    BuiltinIndicators.GetIndicatorByCode(BuiltinIndicators.IndicatorCode.ShapesJagged3Small).Location;
                target1.Pattern = KpiPattern.IncreasingIsBetter;
                target1.RelatedActualId = newKpi.Actual.Guid;
                // set up the banding; 3 bands:  < .5; .5 - 1.0; > 1.0
                target1.Banding.ActualWorst = 0;
                target1.Banding.Type = BandType.Normalized;
                target1.Banding.SpreadMaximum = 1.2M;
                target1.Banding.SpreadMinimum = 0;
                target1.Banding.CustomBoundary.Add(.50M);
                target1.Banding.CustomBoundary.Add(1M);
                newKpi.Targets.Add(target1);
     
                // call SPDataStore to save it to SharePoint
    Hope that helps.

    - Tim
    Developer, Microsoft PerformancePoint
    Thursday, February 18, 2010 8:46 PM
  • Hi Konstantin,

    Try looking in the Application event log on the server.  There should be more information there that will point you to the problem.
    And like I said earlier, try looking at the "InnerException" to see if there is more detail there.

    - Tim


    Developer, Microsoft PerformancePoint
    Friday, February 19, 2010 9:11 PM

All replies

  • Hi Konstantin,
    In your exception handler, try looking at "ex.InnerException" to see if you get some more details as to what is failing.

    My guess: there is some code that checks to see if the KPI is valid.  One of the checks it does is to make sure an "Actual" has been defined, and since you did not define one it is probably throwing an error.

    Here is an example of how to create "fixed value" actuals and targets:

                /*
                 * using Microsoft.PerformancePoint.Scorecards;
                 * using Microsoft.PerformancePoint.Scorecards.Store;
                 * using Microsoft.PerformancePoint.Scorecards.Indicators;
                 */
    
    
                Kpi newKpi = Kpi.CreateNew();
                newKpi.Name.Text = "Test KPI";
                newKpi.Description.Text = "Created via SDK";
    
                // Fixed value actual
                newKpi.Actual.DataSourceLocation = new RepositoryLocation(Constants.FixedValuesDataSourceLocationKey);
                newKpi.Actual.ModelCurrent = 80;    // this sets the value for the actual
    
                // Fixed value target
                Target target1 = new Target();
                target1.Guid = Guid.NewGuid();
                target1.Name.Text = "Target";
                target1.DataSourceLocation = newKpi.Actual.DataSourceLocation;
                target1.ModelCurrent = 100; // this sets the value for the target
                target1.IndicatorLocation =
                    BuiltinIndicators.GetIndicatorByCode(BuiltinIndicators.IndicatorCode.ShapesJagged3Small).Location;
                target1.Pattern = KpiPattern.IncreasingIsBetter;
                target1.RelatedActualId = newKpi.Actual.Guid;
                // set up the banding; 3 bands:  < .5; .5 - 1.0; > 1.0
                target1.Banding.ActualWorst = 0;
                target1.Banding.Type = BandType.Normalized;
                target1.Banding.SpreadMaximum = 1.2M;
                target1.Banding.SpreadMinimum = 0;
                target1.Banding.CustomBoundary.Add(.50M);
                target1.Banding.CustomBoundary.Add(1M);
                newKpi.Targets.Add(target1);
     
                // call SPDataStore to save it to SharePoint
    Hope that helps.

    - Tim
    Developer, Microsoft PerformancePoint
    Thursday, February 18, 2010 8:46 PM
  • Hi Tim,

     

    Thank you for your answer!

     

    We have tried the example you suggested. Unfortunately we received the same exception:

    “The list no longer exists or you do not have permissions to view it. The KPI cannot be saved. Additional details have been logged for your administrator”.

    We have doublechecked permissions for users and list location – it’s everything OK with them. But we can just read, but not create KPIs.

    It looks like there is some specific feature in PPS to SharePoint 2010 connection.

     

    Could you give us any directions regarding this?

     

    Konstantin

    Friday, February 19, 2010 1:32 PM
  • Hi Konstantin,

    Try looking in the Application event log on the server.  There should be more information there that will point you to the problem.
    And like I said earlier, try looking at the "InnerException" to see if there is more detail there.

    - Tim


    Developer, Microsoft PerformancePoint
    Friday, February 19, 2010 9:11 PM