Forum Discussion

NicolasArgente's avatar
NicolasArgente
Valued Contributor
2 years ago

How to reset the InUse entity property to the way it was by default from a BR?

Hello,

I have InUse for default time and scenario = True
I also have InUse for default time and scenario for 2023M5 = False.
Note that the period could also be different.

Now, how could I reset the InUse settings to disable the False or True on ALL time for default Scenario?
In my example above, I am expecting the property for 2023M5 to be deleted. 
What brapi would you use? can you show me an example?
Thanks

  • ChrisLoran's avatar
    ChrisLoran
    Valued Contributor

    It would be useful to have a screen cap of an example, for clarification on the question here.

    Let's say you have an entity , where the InUse property has been set to a stored value for a certain time period:
    Example:

    Now I want to use a BR, to remove the InUse stored value , for the time period 2022M1 on the (Default) scenario type.

    Dim entMbr As MemberInfo = BRApi.Finance.Members.GetMemberInfo(si,DimTypeId.Entity, "Shanghai", True)
    Dim entProps As EntityVMProperties = entMbr.GetEntityProperties()
    						
    Dim idScenarioType As Integer = DimConstants.Unknown ' -- use for (Default) scenario type
    Dim idTime         As Integer = TimeDimHelper.GetIdFromName("2022M1")
    entProps.InUse.RemoveStoredPropertyItem( idScenarioType, idTime )

    By running this code, it has removed the stored value (True) for the InUse property, for 2022M1 for the entity.
    Only the stored value for 2020M1 now remains.

    Now repeat the BR , with time argument of 2020M1:

    Now all the stored values have been removed:

     

    • NicolasArgente's avatar
      NicolasArgente
      Valued Contributor

      Hi ChrisLoran and thanks for stepping in!
      What you are doing in the script is deleting one by one the properties. To achieve that, it means you already know the Time value property that needs to be deleted. How do you get a list of those time values? In your printscreen above, how would you get the list of 2020M1 and 2022M1?
      and is there an api to delete all Time value  properties of the InUse?
      Thanks

      • RobbSalzmann's avatar
        RobbSalzmann
        Valued Contributor II

        NicolasArgente  for time, try si.WorkflowClusterPk.TimeKey

        For scenario, si.WorkflowClusterPk.ScenarioKey

        In your rule:

        Dim sScenario As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)

        Dim sTime As String = BRApi.Finance.Time.GetNameFromId(si, si.WorkflowClusterPk.TimeKey)