Id:String;
The Id property determines data source identifier.
To get data source as a repository object, use the IAdhocDataSourceObject.SourceObjectDescriptor property.
Executing the example requires that the repository contains a dashboard with the DASHBOARD_ID identifier and an express report with the EXP_DSOID identifier.
Add links to the Adhoc, Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Dashboard: IAdhocReport;
DsObjs, DOD: IAdhocDataSourceObjects;
i: Integer;
DsObj: IAdhocDataSourceObject;
mbo, mbos: IMetabaseObject;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get dashboard
mbo := mb.ItemById("DASHBOARD_ID").Edit;
Dashboard := mbo As IAdhocReport;
// Get dashboard data sources
DsObjs := Dashboard.DataSourceObjects;
DsObjs.RemoveById("EXP_DSOID");
DsObjs.RemoveById("EXP_DSO");
//Add a data source
mbos := mb.ItemById("EXP_DSOID") As IMetabaseObject;
DsObj := Dashboard.AddDataSourceObject("EXP_DSOID", mbos);
// Copy data source
DsObj := Dashboard.CopyDataSourceObjectEx(DsObj, "EXP_DSO");
// Remove the first data source
DsObjs.Remove(0);
For i := 0 To DsObjs.Count - 1 Do
// Get data source name
DsObj := DsObjs.Item(i);
Debug.WriteLine("Data source name " + (i + 1).ToString + " - " + DsObj.SourceObjectDescriptor.Name);
// Get data source identifier
Debug.WriteLine("Data source identifier " + (i + 1).ToString + " - " + DsObj.Id);
End For;
// Get the number of sources
DOD := DsObj.DataSourceObjects;
Debug.WriteLine("Number of sources = " + DOD.Count.ToString);
mbo.Save;
End Sub UserProc;
After executing the example a data source is copied to the dashboard, and the EXP_DSO identifier is assigned to it, the console window displays the number of active slides, data source names, data source identifiers, the number of data sources.
See also: