Skip to main content
October 22, 2025
Solved

How to export data out of BR

  • October 22, 2025
  • 2 replies
  • 1 view

Hi All,

I created a Business Rule to export all the GROUPS that i have in OS applciation. i try to export the data in a file. i tried below option , it did not work

  1. created BR and executed there as File output
  2. Created a Data Management Sequence and added 2 steps. 2 for BR and other for File Export. But my File export fails as NAME Empty

Below is the error 
Error processing Data Management Step 'ExportGroups'. Name is empty.

Below is the BR i used.

Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine

Namespace OneStream.BusinessRule.Extender.BRGetAllGroups_1
    Public Class MainClass
        Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
            Try
                ' Get all security groups
                Dim groupsObj As Object = BRApi.Security.Admin.GetGroups(si)
                Dim names As New List(Of String)

                If groupsObj Is Nothing Then
                    names.Add("No security groups found")
                Else
                    Dim enumerable = TryCast(groupsObj, System.Collections.IEnumerable)
                    If enumerable IsNot Nothing Then
                        For Each g In enumerable
                            If g IsNot Nothing Then
                                Dim name As String = g.ToString()
                                If name <> "" AndAlso Not names.Contains(name) Then
                                    names.Add(name)
                                End If
                            End If
                        Next
                    End If
                End If

                ' FORMATTED OUTPUT FOR EASY VIEWING
                Dim output As New List(Of String)
                output.Add("=== SECURITY GROUPS LIST ===")
                output.Add("Generated: " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                output.Add("")
                
                For Each name In names
                    output.Add(name)
                Next
                
                output.Add("")
                output.Add("=== END OF LIST ===")
                output.Add("Total groups: " & names.Count.ToString())
                
                Return output

            Catch ex As Exception
                Dim errorList As New List(Of String)
                errorList.Add("ERROR: " & ex.Message)
                errorList.Add("Generated: " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                errorList.Add("=== END ===")
                Return errorList
            End Try
        End Function
    End Class
End Namespace

Best answer by MarcusH

I don't know why you are making things complicated. sameburn​ gave you a great starting point. I have updated your script.

Try
	' Get all security groups
	Dim groupsObj As List(Of Group) = BRApi.Security.Admin.GetGroups(si)

	' FORMATTED OUTPUT FOR EASY VIEWING
	Dim output As New List(Of String)
	output.Add("=== SECURITY GROUPS LIST ===")
	output.Add("Generated: " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
	output.Add("")
	
	For Each varGroup As Group In groupsObj
		output.Add(varGroup.Name)
	Next
	
	output.Add("")
	output.Add("=== END OF LIST ===")
	output.Add("Total groups: " & groupsObj.Count.ToString())
	
	BRApi.ErrorLog.LogMessage(si, output.ToString)
	
	Return Nothing

Catch ex As Exception
	Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try

Extender rules do not return anything so you will either have to save the file to the fileshare (search this forum for XFFile) or to your user temp folder (search for usertemp in the BR help).

2 replies

MarcusHAnswer
October 22, 2025

I don't know why you are making things complicated. sameburn​ gave you a great starting point. I have updated your script.

Try
	' Get all security groups
	Dim groupsObj As List(Of Group) = BRApi.Security.Admin.GetGroups(si)

	' FORMATTED OUTPUT FOR EASY VIEWING
	Dim output As New List(Of String)
	output.Add("=== SECURITY GROUPS LIST ===")
	output.Add("Generated: " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
	output.Add("")
	
	For Each varGroup As Group In groupsObj
		output.Add(varGroup.Name)
	Next
	
	output.Add("")
	output.Add("=== END OF LIST ===")
	output.Add("Total groups: " & groupsObj.Count.ToString())
	
	BRApi.ErrorLog.LogMessage(si, output.ToString)
	
	Return Nothing

Catch ex As Exception
	Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try

Extender rules do not return anything so you will either have to save the file to the fileshare (search this forum for XFFile) or to your user temp folder (search for usertemp in the BR help).

DK_OSAuthor
October 22, 2025

thanks Marcs,

I was able to export the file to the FileSHare, below is my actual code.

            Try
                ' Get all security groups
                Dim groupsObj As List(Of Group) = BRApi.Security.Admin.GetGroups(si)
                Dim names As New List(Of String)

                For Each varGroup As Group In groupsObj
                    names.Add(varGroup.Name)
                Next

    
                Dim fileName As String = "SecurityGroups"
                Dim filePath As String = $"Documents/Users/{StringHelper.RemoveSystemCharacters(si.UserName, False, False)}"

                ' Use a string builder object
                Dim filesAsString As New StringBuilder()
                
         
                filesAsString.AppendLine("=== SECURITY GROUPS LIST ===")
                filesAsString.AppendLine("Generated: " & DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
                filesAsString.AppendLine("Total Groups: " & names.Count.ToString())
                filesAsString.AppendLine("")
                
                ' Add all group names
                For Each name As String In names
                    filesAsString.AppendLine(name)
                Next
                
                filesAsString.AppendLine("")
                filesAsString.AppendLine("=== END OF LIST ===")

                ' Convert the string to an array of byte
                Dim fileAsByte() As Byte = System.Text.Encoding.Unicode.GetBytes(filesAsString.ToString)

                ' Save file using COMMUNITY METHOD
                Dim fileDataInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, $"{fileName}.txt", filePath)
                Dim fileData As New XFFile(fileDataInfo, String.Empty, fileAsByte)
                BRApi.FileSystem.InsertOrUpdateFile(si, fileData)

                Return Nothing

            Catch ex As Exception
                Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
            End Try
      

 

Appreciate your help on this. I need to update the security USERS/GROUPS from a CSV file.

Should i ABle to update using BR to the backend tables or should i use the BR API similar to the above code.

1. Update user access , remove or add groups
2. Update Users - delete or add new users

 


May i ask you one more question, i am not great in VB.net coding. is there any specific course or site that i should go through to understand the API and functions calling details?

October 22, 2025

I did a quick search for Business Rule training courses. Here are two I found (I have not attended either of them and I have no knowledge about them):

https://keyteach.com/component/content/article/onestream-writing-financial-calculations-3-days?catid=12

https://hollandparker.com/onestream-public-training/

The best place for getting more information is first in the online BR help and then search this forum.