Forum Discussion

Marco's avatar
Marco
Contributor II
5 months ago

Remove text from entities in Data Management

Hi Everyone.

I have some entities that have text at the end, for example “_Test”, and what I want to do is that in the data management I can remove the text at the end to use the original entities.
Example: 12001_12000_Test to 12001_12000

I want to remove that in the section that is in the image, so I wanted to know if it is possible or if there is a solution so that the api.Data.calculate and api.Data.SetDataCell use that entity without the “_Test”.

 

  • I think I am missing something but I think you just need to manipulate the source entity and leave the entity off the destination side. 

    You are copying from Entity to Entity_Test, correct?

    If you define the _Test entities in the DM Step then your rule would look like this:

    Dim povEntity As String = api.Pov.Entity.Name
    Dim povEntityRemove_Test As String = povEntity.Replace("_Test","")
    api.Data.calculate("A#S_HEADCOUNT = E#" & povEntityRemove_Test & ":A#Headcount")

     

  • TheJonG's avatar
    TheJonG
    Contributor III

    Hi Marco - if I am understanding your question correctly, the entities returned by E#Root.WFProfileEntities would all have '_Test' at the end and you'd like to have the '_Test' removed?

    If this is correct, you can do this through an XFBR rule which loops through the entities and removes "_Test". I have pasted some sample code below. To implement, you can replace E#Root.WFProfileEntities with XFBR(MarcoParamHelper, RemoveTestFromEntities) in the Entity filter of you Data Management step.

    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.DashboardStringFunction.MarcoParamHelper
    	Public Class MainClass
    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardStringFunctionArgs) As Object
    			Try
    				If args.FunctionName.XFEqualsIgnoreCase("RemoveTestFromEntities") Then
    					
    					Dim wfProfileEntities As List(Of WorkflowProfileEntityInfo) = BRApi.Workflow.Metadata.GetProfileEntities(si, si.WorkflowClusterPk.profileKey)
    					
    					Dim newEntityList As New Text.StringBuilder
    					Dim isFirstItem As Boolean = True
    					
    					For Each wfProfileEntity As WorkflowProfileEntityInfo In wfProfileEntities
    						
    						Dim wfProfileEntityName As String = wfProfileEntity.EntityName
    						
    						If isFirstItem Then
    							newentityList.Append("E#" & wfProfileEntityName.Replace("_Test",""))
    						Else
    						
    							newentityList.Append(",E#" & wfProfileEntityName.Replace("_Test",""))
    						End If
    						
    						isFirstItem = False
    					Next
    					
    					Return newEntityList.ToString
    				End If
    
    				Return Nothing
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Function
    	End Class
    End Namespace

     

     

    • Marco's avatar
      Marco
      Contributor II

      Hi Jon.
      I already had my method to do it in the BR, but I had this question because I am running the following

      api.Data.calculate("Cb#[HLFPLN]:S#" & strScenario & ":E#"& strEntity_O &":O#Import:A#S_HEADCOUNT:F#None:U5#None:U6#None = Cb#[HLFPLP]:S#" & strScenario & ":E#"& strEntity &":O#Top:A#Headcount:F#TotalEmployeeFlow:U5#PLPDrivers:U6#PLPStatusBase")

      where strEntity_O is the entity without the text, and strEntity is with the text, but I understand that the data calculate uses the entity that comes from the data management, and that is where I have an error “Invalid destination data unit in script”.do you know a way to solve this?

      • TheJonG's avatar
        TheJonG
        Contributor III

        You cannot have an entity specified in the destination script as it is inherited from the POV which comes from the DM Step as you said. Are you trying to copy data from Entity_Test to Entity? If so, you can declare a variable to get the POV entity (from the DM step) and then add the _Test to it and reference that in the source script and remove the entity from the destination script altogether.