How to export data out of BR
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
- created BR and executed there as File output
- 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
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).