Forum Discussion

NoorMohd's avatar
NoorMohd
New Contributor
26 days ago

Entity Relationship Properties update via business rules

Hi Team,

 

I would like to fetch and update the Entity Relationship Properties for the Entity Dimension members via Business Rules.

The below peace of code works fine for only when I pass the Actual and Budget but when i pass the other scenario Type like Scenariotype 1 to 8   I get the error Object is not set to an instance of an object.

Dim Scenario As String = args.CustSubstVarsAlreadyResolved("Param_SecnarioType_EO_24")

'The above value i get it from the combo box as delimited list

 Dim Scenarioid As Integer = BRApi.Finance.Members.GetMemberId(si,dimtype.Scenario.Id,Scenario)
Dim MyScenarioTypeid As ScenarioType = BRApi.Finance.Scenario.GetScenarioType(si,Scenarioid)
Dim Timefilter As String = args.CustSubstVarsAlreadyResolved("Param_Time_24")
Dim Timeid As Integer = BRApi.Finance.Members.GetMemberId(si,dimtype.Time.Id,Timefilter)

Can you please help me with the correct way to get the scenario Type.

  • I would suspect you are getting the error should your Scenario variable not resolve to a valid Scenario member.  In that case ScenarioId will be DimConstants.Unknown.  Attempting to get the ScenarioType of an unknown member will then barf.  Put differently, you should only attempt to get the ScenarioType if ScenarioId<>DimConstants.Unknown.

  • I think your method looks correct. However, be a little careful with how you name variables etc so that you dont interfere with keywords used by the platform in other ways.

    For example, as a quick test, try this in an externder rule, its doing exactly the same as your example above but with hardcoded Scenario name and different named variables:

    Dim varScen As String = "NameOfScenario" 
    Dim Scenarioid As Integer = BRApi.Finance.Members.GetMemberId(si,dimtype.Scenario.Id,varScen)
    Dim MyScenarioTypeid As ScenarioType = BRApi.Finance.Scenario.GetScenarioType(si,Scenarioid)
    
    Throw New Exception("ScenarioType of "& varScen &" is: "& MyScenarioTypeid.Name)