Forum Discussion

Shetal_P's avatar
Shetal_P
New Contributor II
3 years ago

Extract Active Entity list from OneStream by using Data Management Job

Hi all, Happy New Year! Is there a way of extracting an active entity list from OneStream including Entity Name, Description, and Currency fields by using a data management job? Any ideas will be app...
  • Sai_Maganti's avatar
    Sai_Maganti
    3 years ago

    I see why you want to use a DM. Here is some basic BR which gets the list of entities from member info and writes a csv file to the system. You may modify to suit your requirements.

    Namespace OneStream.BusinessRule.Extender.ExportEntitiesMetaData
    	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
    				Select Case args.FunctionType					
    					Case Is = ExtenderFunctionType.Unknown, ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep
    										
    					Dim configSettings As AppServerConfigSettings = AppServerConfig.GetSettings(si)
    					Dim folderPath As String = FileShareFolderHelper.GetDataManagementExportUsernameFolderForApp(si, True, configSettings.FileShareRootFolder, si.AppToken.AppName) & "\MetaData"
    					If Not Directory.Exists(folderPath) Then Directory.CreateDirectory(folderPath)
    					Dim filePath As String = folderPath & "\EntityList.csv"				
    					If File.Exists(filePath) Then File.Delete(filePath)
    				
    					Using dbConnFW As DbConnInfo = BRAPi.Database.CreateFrameworkDbConnInfo(si)
    						Using dbConnApp As DbConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)
    							'Get the Members using member script
    							Dim mf As String = "E#YourEntityTop.Base"
    							'Set up entity dimension
    							Dim objDim As OneStream.Shared.Wcf.Dim = DimsWcf.GetDimUsingName(dbConnFW, dbConnApp, "Entities")
    							Dim members As List(Of MemberInfo) = MetadataWcf.GetMembersUsingFilter(dbConnFW, dbConnApp, Nothing, si.WorkflowClusterPk, si.PovDataCellPk, objDim.DimPk, mf, 0, Nothing, Nothing, True, False, True)							
    								
    							Dim sb As New StringBuilder
    							sb.AppendLine("Name,Description,Currency")
    							For Each memInfo As MemberInfo In members 					
    								sb.AppendLine(memInfo.Member.Name & "," & memInfo.Member.Description.Replace(",", "_") & "," & BRApi.Finance.Entity.GetLocalCurrency(si, memInfo.Member.MemberId).Name)
    							Next
    							' Write the output string to a file
    							Dim sw As New StreamWriter(filePath)
    							sw.Write(sb)
    							sw.Close()						
    						End Using
    					End Using						
    				End Select
    
    				Return Nothing
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Function
    	End Class
    End Namespace
  • Koemets's avatar
    Koemets
    3 years ago

    It's InUse function, use it as follows:

    For Each memInfo As MemberInfo In members

       Dim boolInUse As Boolean = BRApi.Finance.Entity.InUse(si, memInfo.Member.MemberID, varyByScenarioTypeId, varyByTimeId)

       If boolInUse Then

            sb.AppendLine(memInfo.Member.Name...

    ETC...

     

    Make sure you define varybyscenario and varybytime types in the InUse function.