Call Data Adapter in BR and Store Results in External Database Table

Bella_Yu
New Contributor II

I would like to export data from existing OneStream dashboard and load it into external database table. I did some research and below is a draft business rule written in Visual Basic. What it does is to call data adapter and store the results. Next step is to load data from DataTable into external database table.

Questions is, it gives a warning "Function GetAdoDataSetForAdapter is obsolete", what is the current supported function? 

Error.png

 

Dim dctVars As New Dictionary(Of String, String)
Using ds As DataSet = brapi.Dashboards.Process.GetAdoDataSetForAdapter(si, False, "AdapterName", "ResultsTable", dctVars)
	If ds.Tables.Count > 0 Then ' -- If there are >0 tables in the results
		Using dt As DataTable = ds.Tables(0).Copy()
		Return dt 
		End Using
	End If
End Using

 

1 ACCEPTED SOLUTION

MarcusH
Contributor III

In the Business Rules editor if you type:

brapi.Dashboards.Process.GetAdoDataSetForAdapter(

it will give you the intellisense for the function which is like this:

MarcusH_0-1714034153887.png

1 - says 1 of 2 so there is another definition of this function with different parameters (ie overloaded)

2 - says the current definition is deprecated which is why you are getting the warning.

Click on the down arrow in area 1 and it gives you this:

MarcusH_1-1714034262952.png

which tells you the function needs the workspace id before the workspace/dashboard name.

 

View solution in original post

3 REPLIES 3

MarcusH
Contributor III

In the Business Rules editor if you type:

brapi.Dashboards.Process.GetAdoDataSetForAdapter(

it will give you the intellisense for the function which is like this:

MarcusH_0-1714034153887.png

1 - says 1 of 2 so there is another definition of this function with different parameters (ie overloaded)

2 - says the current definition is deprecated which is why you are getting the warning.

Click on the down arrow in area 1 and it gives you this:

MarcusH_1-1714034262952.png

which tells you the function needs the workspace id before the workspace/dashboard name.

 

Bella_Yu
New Contributor II

Thanks for your detailed explanation, really helpful!

RobbSalzmann
Valued Contributor

Hi @Bella_Yu ,

Returning an object that is managed by an enclosing using block is going to lead to problems.  Most likely if the calling code doesn't finish with dt before the enclosing Using disposes of it, you will get somewhat random errors.

Instead, return an object that is not managed by a Using block:

Dim dctVars As New Dictionary(Of String, String)
Using ds As DataSet = brapi.Dashboards.Process.GetAdoDataSetForAdapter(si, False, "AdapterName", "ResultsTable", dctVars)
    If ds.Tables.Count > 0 Then ' -- If there are >0 tables in the results
        Using dt As DataTable = ds.Tables(0)
            Dim clonedDt As DataTable = dt.Copy() ' Clone the DataTable
            Return clonedDt
        End Using
    End If
End Using

Ideally, you should simply return dt without the using block and manage it in the calling method.