IAdhocReport.AddDataSourceLinkedObject

Fore Syntax

AddDataSourceLinkedObject(Id: String; Object: IMetabaseObject): IAdhocDataSourceObject;

Fore.NET Syntax

AddDataSourceLinkedObject(Id: string; Object: Prognoz.Platform.Interop.Metabase.IMetabaseObject): Prognoz.Platform.Interop.AdHoc.IAdhocDataSourceObject;

Parameters

Id. Dashboard object identifier.

Object. Repository object.

Description

The AddDataSourceLinkedObject method adds a block of the Express Report, Regular Report or Dashboard type.

Comments

To add a data source to visualizers, use the IAdhocReport.AddDataSourceObject property.

Fore Example

Executing the example requires that the repository contains a dashboard with the DASHBOARD_ADSLO identifier and an express report with the EXP_ADSLO identifier.

Add links to the Adhoc, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Dashboard: IAdhocReport;
    DsObjs, DsOdjsL: IAdhocDataSourceObjects;
    i: Integer;
    DsObj: IAdhocDataSourceObject;
    mbo, mbol: IMetabaseObject;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get dashboard
    mbo := mb.ItemById("DASHBOARD_ADSLO").Edit;
    Dashboard := mbo As IAdhocReport;
    // Get dashboard data sources
    DsObjs := Dashboard.DataSourceObjects;
    DsOdjsL := Dashboard.DataSourceLinkedObjects;
    DsOdjsL.RemoveById("EXP_ADSLO");
    //Add a new linked data source
    mbol := mb.ItemById("EXP_ADSLO"As IMetabaseObject;
    DsObj := Dashboard.AddDataSourceLinkedObject("EXP_ADSLO", mbol);
    For i := 0 To DsOdjsL.Count - 1 Do
        // Get data source identifier
        DsObj := DsOdjsL.Item(i);
        Debug.WriteLine("data source identifier " + (i + 1).ToString + " - " + DsObj.Id);
    End For;
    mbo.Save;
End Sub UserProc;

After executing the example the console window displays data source identifiers. A linked data source is added to the dashboard.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Adhoc;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Dashboard: IAdhocReport;
    DsObjs, DsOdjsL: IAdhocDataSourceObjects;
    i: Integer;
    DsObj: IAdhocDataSourceObject;
    mbo, mbol: IMetabaseObject;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get dashboard
    mbo := mb.ItemById["DASHBOARD_ADSLO"].Edit();
    Dashboard := mbo As IAdhocReport;
    // Get dashboard data sources
    DsObjs := Dashboard.DataSourceObjects;
    DsOdjsL := Dashboard.DataSourceLinkedObjects;
    DsOdjsL.RemoveById("EXP_ADSLO");
    //Add a new linked data source
    mbol := mb.ItemById["EXP_ADSLO"As IMetabaseObject;
    DsObj := Dashboard.AddDataSourceLinkedObject("EXP_ADSLO", mbol);
    For i := 0 To DsOdjsL.Count - 1 Do
        // Get data source identifier
        DsObj := DsOdjsL.Item[i];
        System.Diagnostics.Debug.WriteLine("data source identifier " + (i + 1).ToString() + " - " + DsObj.Id);
    End For;
    mbo.Save();
End Sub;

See also:

IAdhocReport