SPDataStore.UpdateKpi method
Updates a key performance indicator (KPI) in a SharePoint list.
Namespace: Microsoft.PerformancePoint.Scorecards.Store
Assembly: Microsoft.PerformancePoint.Scorecards.Store (in Microsoft.PerformancePoint.Scorecards.Store.dll)
Syntax
'Declaration
Public Function UpdateKpi ( _
kpi As Kpi _
) As Kpi
'Usage
Dim instance As SPDataStore
Dim kpi As Kpi
Dim returnValue As Kpi
returnValue = instance.UpdateKpi(kpi)
public Kpi UpdateKpi(
Kpi kpi
)
Parameters
kpi
Type: Microsoft.PerformancePoint.Scorecards.KpiThe KPI object that contains the updated information. The Location property must specify the URL of the object to update.
Return value
Type: Microsoft.PerformancePoint.Scorecards.Kpi
The updated object, which contains updated information such as the new version number.
Implements
IBIMonitoringStore.UpdateKpi(Kpi)
Remarks
For kpi, we recommend that you use a KPI object that was previously retrieved by using the GetKpi(RepositoryLocation) method.
Examples
The following code example shows how to retrieve a KPI, update the retrieved KPI, and then save the updated object to the repository.
Before you can compile this code example, you must do the following:
Configure your development environment and create a C# class library project in Visual Studio. For information about configuring a development environment, see Set up a general development environment for SharePoint 2013.
Add the Microsoft.PerformancePoint.Scorecards.Client, Microsoft.PerformancePoint.Scorecards.ServerCommon, and Microsoft.PerformancePoint.Scorecards.Store DLLs as references to your project. For more information about PerformancePoint Services DLLs, see PerformancePoint Services DLLs Used in Development Scenarios.
Add the following using directives to your class.
using Microsoft.PerformancePoint.Scorecards; using Microsoft.PerformancePoint.Scorecards.Store; using System.Globalization;
Create a method that does the following:
Defines a string variable named "relativePath" to store the server-relative path to the object. The following example path sets the object identifier to "5": /BI Center/Lists/PerformancePoint Content/5_.000.
Creates an instance of a Kpi object named "updatedKpi." For an example of how to create the object, see the CreateKpi method.
Paste the following code example into the new method.
// As a best practice, retrieve the object and then update it.
// The RepositoryLocation constructor takes the server-relative path to the object.
Kpi requestedKpi = SPDataStore.GlobalDataStore.GetKpi(new RepositoryLocation(relativePath));
if (requestedKpi != null)
{
// Update the description to show the time of the last update operation.
requestedKpi.Description.Text = String.Format(
CultureInfo.CurrentCulture,
"Last updated at {0}",
DateTime.Now.ToLocalTime());
// Update the KPI in the repository.
updatedKpi = SPDataStore.GlobalDataStore.UpdateKpi(requestedKpi);
}