Selecting Default Dictionary Element

The examples in Fore and Fore.NET example show setting a default element in a dictionary and selecting this element in express report using the dictionary as one of the dimensions.

Executing the examples requires that the repository contains an MDM table dictionary with the RDS_DICT_OBJ identifier. A selection scheme is added for the dictionary. The dictionary is a standard cube dimension, on which express report with the EAX_OBJ identifier is built.

After executing the example a default element is set for the dictionary, and one element that is a default element is selected on opening the express report in this dimension.

Example

Add links to the Dimensions, Express, Metabase, Pivot, Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    Selection: IDimSelection;
    PreSchema: IPredefinedSelectionSchema;
    Obj: IMetabaseObject;
    Dict: IRdsDictionary;
Begin
    
// Get current repository
    MB := MetabaseClass.Active;
    
// Get table MDM dictionary
    Obj := MB.ItemById("RDS_DICT_OBJ").Edit;
    Dict := Obj 
As IRdsDictionary;
    
// Set default element key in table MDM dictionary
    Dict.DefaultElementKey := 11;
    
// Get express report
    Express := MB.ItemById("EAX_OBJ").Edit As IEaxAnalyzer;
    
// Get selection of the dimension, which contains default element
    Selection := Express.Pivot.Selection.Item(1);
    
// Get predetermined dimension selection scheme
    PreSchema := Selection.PredefinedSchema;
    
If (PreSchema <> NullThen
        PreSchema.Clear;
        PreSchema.Add(SelectionPrimitiveType.DefaultElement);
        
// Use predetermined dimension selection scheme
        PreSchema.Active := True;
    
End If;
    (Express 
As IMetabaseObject).Save;
End Sub userproc;

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Express;
Imports Prognoz.Platform.Interop.Pivot;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Express: IEaxAnalyzer;
    Selection: IDimSelection;
    PreSchema: IPredefinedSelectionSchema;
    Obj: IMetabaseObject;
    Dict: IRdsDictionary;
Begin
    
// Get current repository
    MB := Params.Metabase;
    
// Get table MDM dictionary
    Obj := MB.ItemById["RDS_DICT_OBJ"].Edit();
    Dict := Obj 
As IRdsDictionary;
    
// Set default element key in table MDM dictionary
    Dict.DefaultElementKey := 11;
    
// Get express report
    Express := MB.ItemById["EAX_OBJ"].Edit() As IEaxAnalyzer;
    
// Get selection of the dimension, which contains default element
    Selection := Express.Pivot.Selection.Item[1];
    
// Get predetermined dimension selection scheme
    PreSchema := Selection.PredefinedSchema;
    
If (PreSchema <> NullThen
        PreSchema.Clear;
        PreSchema.Add(SelectionPrimitiveType.sptDefaultElement);
        
// Use predetermined dimension selection scheme
        PreSchema.Active := True;
    
End If;
    (Express 
As IMetabaseObject).Save();
End Sub;

See also:

Examples | IRdsDictionary