SPDataStore.CreateFilter Method

Saves a filter object as a content type in a SharePoint list.

Namespace:  Microsoft.PerformancePoint.Scorecards.Store
Assembly:  Microsoft.PerformancePoint.Scorecards.Store (in Microsoft.PerformancePoint.Scorecards.Store.dll)

Syntax

'Declaration
Public Function CreateFilter ( _
    listUrl As String, _
    filter As Filter _
) As Filter
'Usage
Dim instance As SPDataStore
Dim listUrl As String
Dim filter As Filter
Dim returnValue As Filter

returnValue = instance.CreateFilter(listUrl, _
    filter)
public Filter CreateFilter(
    string listUrl,
    Filter filter
)

Parameters

  • listUrl
    Type: System.String

    The server-relative URL of the SharePoint list to save the object to. Example: /BI Center/Lists/PerformancePoint Content.

  • filter
    Type: Microsoft.PerformancePoint.Scorecards.Filter

    The filter object to save, which specifies values for the required Name property. For custom filters, filter must also specify the SubTypeId property, and the value must match the subType attribute specified for the custom filter in the web.config file for PerformancePoint Services in Microsoft SharePoint Server 2010.

Return Value

Type: Microsoft.PerformancePoint.Scorecards.Filter
The new object, which contains updated information such its location and version number.

Implements

IBIMonitoringStore.CreateFilter(String, Filter)

Examples

The following code example shows how to use a private method to create a filter and to call CreateFilter(String, Filter) to save it to the repository.

Before you can compile this code example, you must do the following:

// Create a member selection filter that uses the Adventure Works sample cube.
//   - filterName is the name for the filter.
//   - listUrl is the server-relative URL of the list to save the filter to. Example: 
//      "/BI Center/Lists/PerformancePoint Content"
//   - ds is the data source to use for the filter.
// This method returns the new filter.
private Filter CreateMemberSelectionFilter(string filterName, string listUrl, DataSource ds)
{
    if (String.IsNullOrEmpty(filterName))
throw new ArgumentException("The name must not be null or empty.");
    if (String.IsNullOrEmpty(listUrl))
        throw new ArgumentException("The list URL must not be null or empty.");
    if (null == ds)
        throw new ArgumentNullException("ds");

    Filter newFilter = Filter.CreateNew();
    newFilter.Name.Text = filterName;
    newFilter.Description.Text = "Created with the SDK.";
    newFilter.DataSourceLocation = ds.Location;
    newFilter.SubTypeId = ParameterTemplateId.MemberSelection;

    // Define the filter visualization as a multi-select tree.
    newFilter.SelectionMode = FilterSelectionMode.MultiSelect;
    newFilter.Visualization = FilterVisualization.MultiSelectTree.ToString();

    // The parameter definition defines the filter type and query.
    ParameterDefinition parameterDef = new ParameterDefinition();
    newFilter.BeginPoints.Add(parameterDef);
    parameterDef.DisplayName = newFilter.Name.Text;
    parameterDef.DefaultPostFormula = Constants.PostFormulaSourceColumnMoniker;

    // The ParameterProviderId property must match the name of a provider registered in
    // the CustomParameterDataProviders section of the PerformancePoint Services web.config file.
    // The default path to the web.config file is 
    // %ProgramFiles%\Microsoft Office Servers\14.0\WebServices\PpsMonitoringServer.
    parameterDef.ParameterProviderId = "MemberParameterDataProvider";

    // Define the how members are selected from the cube. This type of filter
    // uses MemberParameterDefinition.
    // Selection definitions used by other types of filters are ParameterDefinition,
    // MdxParameterDefinition, and NamedSetParameterDefinition.
    MemberParameterDefinition customDefinition = new MemberParameterDefinition();

    // Create a filter on the Customer Geography dimension.
    // One method is to create a Dimension object manually by hard-coding 
    // the name, as follows.
    customDefinition.Dimension = new Dimension("Customer Geography",
        "[Customer].[Customer Geography]", 
        "Customer Geography Dimension");

    // But as a best practice, you should get the full dimension definition
    // from the cube. This enables full editing within Dashboard Designer.
    // This code assumes it is running on the front-end Web server (for example,
    // in a Web Part), so it uses the service application proxy to call the
    // service application on the back-end server.
    // TODO: Handle exceptions from this call.
    Cube filterCube = BIMonitoringServiceApplicationProxy.Default.GetCube(ds.Location);
    if (filterCube != null)
    {
        try
        {
            customDefinition.Dimension = filterCube.Dimensions["[Customer].[Customer Geography]"];
}
        catch (Exception)
        {
            // TODO: Add error handling.
        }
    }

    // For the filter, use Australia, France, and their child elements.
    Member aus = new Member("[Customer].[Customer Geography].[Country].&[Australia]")
    {
        Caption = "Australia",
        LevelName = "[Customer].[Customer Geography].[Country]"
    };
    Member france = new Member("[Customer].[Customer Geography].[Country].&[France]")
    {
        Caption = "France",
        LevelName = "[Customer].[Customer Geography].[Country]"
    };
    Member ausChildren = (Member) aus.Clone();
    ausChildren.MemberType = MemberType.Operation;
    ausChildren.LevelDepth = 1;
    ausChildren.MemberOperation = new MemberOperationChildren();

    Member franceChildren = (Member) france.Clone();
    franceChildren.MemberType = MemberType.Operation;
    franceChildren.LevelDepth = 1;
    franceChildren.MemberOperation = new MemberOperationChildren();

    customDefinition.Members.Add(aus);
    customDefinition.Members.Add(france);
    customDefinition.Members.Add(ausChildren);
    customDefinition.Members.Add(franceChildren);

    // Define France and Australia as the default selections.
    customDefinition.DefaultMembers.Add(aus);
    customDefinition.DefaultMembers.Add(france);

    parameterDef.CustomDefinition = MemberParameterDefinition.Serialize(customDefinition);

    // Call the service application to get the display data definition.
    // TODO: Handle exceptions from this call.
    System.Data.DataTable dt = 
        BIMonitoringServiceApplicationProxy.Default.GetParameterDisplayData(
            RepositoryLocation.Empty(), 
            newFilter.BeginPoints[0], 
            ds.Location, 
            null);

    if (dt != null)
    {
        parameterDef.DisplayValues = dt.Clone();
        parameterDef.DisplayValues.Rows.Clear();
    }
    else
    {
        // TODO: Add error handling.
    }

    // Call the CreateFilter method to save the new filter to the specified list.
    // TODO: Handle exceptions from this call.
    return SPDataStore.GlobalDataStore.CreateFilter(listUrl, newFilter);
}

See Also

Reference

SPDataStore Class

SPDataStore Members

Microsoft.PerformancePoint.Scorecards.Store Namespace

Other Resources

Create Filter Extensions for PerformancePoint Services