IPrxDataSource.Refresh

Syntax

Refresh(Dimension: IMetabaseObjectDescriptor; [Instance: IDimInstance = Null]): Boolean;

Parameters

Dimension. The dimension included to the cube, which is a data source.

Instance. The dictionary instance to work with elements.

Description

The Refresh method updates slice dimension.

Comments

To get dictionary instance (the Instance parameter) and work with elements, use the IMetabaseObjectDescriptor.Open method and cast the dictionary to the IDimInstance interface.

Example

To execute the example:

  1. Create a regular report.

  2. Add a cube as a data source containing MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers. The MDM dictionaries contain attributes with the NAME and ORD identifiers.

  3. Add a slice to data area .

  4. Drag the added slice to the report sheet using Drag&Drop.

  5. Add two controls for MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers.

  6. Add the Metabase, Report, Rds, Dimensions system assemblies in units.

  7. Create the first unit to work with elements of the MDM dictionary with the D_FACTS identifier:

Sub UserProc;
Var
    Report: IPRxReport;
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key, i: Integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    // Get active regular report
    Report := PrxReport.ActiveReport;
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item(0);
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace("D_FACTS"159).Bind;
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData;
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData;
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in the report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor, DimI);
End Sub UserProc;

  1. Connect the first unit to the report.

  2. Add text with hyperlink in order to execute procedure or function. Select the first unit connected previously to the report.

  3. Create the second unit to work with elements of the MDM dictionary with the DIC_SOURCE identifier:

Sub UserProc;
Var
    Report: IPRxReport;
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key, i: Integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    // Get active regular report
    Report := PrxReport.ActiveReport;
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item(0);
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace("DIC_SOURCE"159).Bind;
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData;
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData;
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in the report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor);
End Sub UserProc;

  1. Connect the second unit to the report.

  2. Add text with hyperlink in order to execute procedure or function. Select the second unit connected previously to the report.

In regular report, after clicking the first hyperlink, one element is added to the MDM dictionary with the D_FACTS identifier, and after clicking the second hyperlink two elements are added to the MDM dictionary with the DIC_SOURCE identifier. The difference in results is that on refreshing dimension in report, the dictionary instance to work with the DimI elements (the Instance parameter) is set and it was not set for the second unit. New elements of MDM dictionaries are displayed in the report controls.

See also:

IPrxDataSource