OSAdmin
Valued Contributor

Open a Dashboard file resource and retrieve its raw contents.

Note: This snippet is for OneStream 7.4 and above. Previous releases can use similar logic, just without the WorkspaceID machinery.

' *** parameters to customize to your needs
' Specify the name of the dashboard file we want to retrieve 
Dim fileResourceName As string = "FileName.txt" 
' Specify the name of the Workspace containing it
Dim workspaceName as String = "My Workspace"
' set this to True if your Dashboard is in the System pane
Dim isSystemLevel as Boolean = False
' *** end parameters

' the following chunk will find the ID of the workspace containing the file
Dim workspaceID = Guid.Empty
If not workspaceName.XFEqualsIgnoreCase("Default") then
    Dim workspaceID as Guid = BRApi.Dashboards.Workspaces.GetWorkspaceIDFromName( _
       si, isSystemLevel, workspaceName)
end if

' Now we retrieve the FileResource object, representing our file
Dim fileResource As DashboardFileResource  = BRApi.Dashboards.FileResources.GetFileResource( _
   si, isSystemLevel, workspaceID, fileResourceName)

' If the file contains text, you can retrieve it right away with the following line.
' NOTE: if it's some other type (zip, image, etc), you will need different handling.
Dim fileContent As String = system.Text.Encoding.UTF8.GetString(fileResource.FileBytes)
Version history
Last update:
‎10-26-2023 07:02 AM
Updated by:
Contributors