07-29-2024 02:32 PM - edited 07-29-2024 02:33 PM
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”.
Solved! Go to Solution.
07-30-2024 06:20 PM
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")
07-29-2024 03:20 PM
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
07-29-2024 06:39 PM
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?
07-29-2024 08:44 PM
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.
07-30-2024 12:07 PM
my problem is that the test entities are located in different places, so I don't know if there is a possibility to configure the api.data.calculate or make it work that way without problem
07-30-2024 03:50 PM
What do you mean the entities are in different places? Do you mean different cubes?
07-30-2024 05:07 PM
I say that the entities that have _test have different parents, and likewise I am making the copy from PLP to PLN.So there is no way to configure the api.data.calculate to work as I expect it to?
07-30-2024 06:20 PM
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")
07-30-2024 07:01 PM
I was referring to the case of modifying the api.Data.Calculate to change the entities that it has for the Data Management, this to change the entities that the function with _Test has inside, to remove them. since the problem of the entities I mentioned, is that they are in those parents that are not the dummy, and they are not together in a place to put that section in the entities of the data management.
07-30-2024 08:07 PM
The only way to run an api.Data.Calculate in an entity that is not in the POV is to kickoff a CustomCalculcate rule from the Business Rule. You can pass in the right entity in through the param dictionary.
Dim brParamDict As New Dictionary(Of String, String) From {{"Cube", api.Pov.Cube.name},
{"Entity", "NewEntityName},
{"Consolidation", "Local"},
{"Scenario", api.Pov.Scenario.Name},
{"Time", timedimhelper.GetYearFromId(api.Pov.Time.MemberId)},
{"View", "YTD"}}
'Trigger custom calculate
BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, "CustomCalcRule", "RuleName", brParamDict, CustomCalculateTimeType.CurrentPeriod)
08-01-2024 09:48 AM
Thank you very much Jon for the help, I used an XFBR String to be able to treat those entities and it worked for me, thank you for answering every doubt.