Opening Express Report with Cube Parameters and Selection Selected

Below is given the example of express report opening with setting of cube parameters and/or selection.

Executing the example requires express report with the OBJ29850 identifier created on the cube with parameters. It is also required to connect the Express, Metabase, Ui, Pivot, Dimensions system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Mb: IMetabase;
    Obj: IMetabaseObject;
    Params: IMetabaseObjectParamValues;
    Target: IUiCommandTarget;
    Context: IUiCommandExecutionContext;
    ex: IEaxAnalyzer;
    Pivot: IPivot;
    Selection: IDimSelection;
Begin
    MB := MetabaseClass.Active;
    Obj := MB.ItemById("OBJ29850").Edit;
    ex := Obj As IEaxAnalyzer;
    // Set value to the parameter
    Params := ex.ParamValues;
    Params.Item(0).Value := "15";
    ex.ParamValues := Params;
    // Set selection to calendar dimension
    Pivot := ex.Pivot;
    Pivot.BeginSelectionUpdate;
        Selection := Pivot.Selection.FindById("D_CALENDAR");
        Selection.DeselectAll;
        Selection.SelectElement(2False);
    Pivot.EndSelectionUpdate;
    Target := WinApplication.Instance.GetPluginTarget("Express");
    Context := Target.CreateExecutionContext;
    Context.Data := ex;
    Target.Execute("ShowReporter", Context);
End Sub Button1OnClick;

After executing the example the express report is opened, the first cube parameter is set to 15. In the dimension with the D_CALENDAR identifier the third dimension element is selected.

See also:

Examples