Forum Discussion

KH1's avatar
KH1
Contributor
12 days ago
Solved

Run "Business Rule" via "Member Formula"

Pls share how to run
1. a traditional BR via a member formula
2. an assembly BR via a member formula
Thank you - OS SME.

  • All I believe you can call directly from a Member Formula, or Formula for Calculation Drill Down are Finance type Business Rules, which is what the code sample I provided was calling.  The reason for this is that there is no way in a dimension member of defining Referenced Assemblies, as you can with all types of Business Rules files.  Being unable to define Referenced Assemblies, the following sample Dim statement to hook in an Assembly file will fail:

    Dim XX As New Workspace.RHWorkspace.RHAssembly.RHStandardClassFile

    To overcome this, you would need to have the Member Formula or Formula for Calculation Drill Down to call a Finance type Business Rule, where you have defined any Referenced Assemblies you desire to non-Finance type rules files, at which point you can call any type of Business Rule file or Assembly file you desire.

    I use the above strategy with all stored Member Formulas, Formula for Calculation Drill Down and many Dynamic Calcs.  They all call functions in Finance type Business Rules files.  That allows me to centrally see/maintain all Member Formulas.  But as importantly, it allows these Member Formulas to make use of common (shared) functions and structures that I use throughout my logic.  The common functions & structures are mostly stored in Extender Rules files.  I can similarly call Workspace assembly files too.  And it also provides the option to write in VB or C# and to encrypt code that is sensitive.

9 Replies

  • Sweez's avatar
    Sweez
    Contributor

    Found this post today as I am wondering the same thing.  It seems the options are limited because we cannot control the import in a member formula from what I understand. Anyway, sorry no answer for you but will be curious if someone has a solution.

    • rhankey's avatar
      rhankey
      Contributor II

      This should give you the idea:

      Dim UDHelper As New OneStream.BusinessRule.Finance.Finance_Foundation.MainClass
      Return UDHelper.GetUD7EntityTextProperties_Dyn(si,globals,api,args)

       

  • Sweez's avatar
    Sweez
    Contributor

    What is "Finance_Foundation" is this example (assembly name, workspace name, etc)?

    • rhankey's avatar
      rhankey
      Contributor II

      "Finance_Foundation" is the Namespace.  "GetUD7EntityTextProperties_Dyn" is the function or sub within the namespace.

      • KH1's avatar
        KH1
        Contributor

        Pls confirm that your code will also call an assembly BR.
        TY - rhankey.

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    While this may be possible, I wonder why?  What is the use-case for wanting to do this?

    By design, member formulas are small, atomic bits of code that run quickly enough to not affect query performance on the cube.

    If you need more complex logic, or the same logic in many member formulas,  using a BR in a workflow would likely be a better design choice.

  • Sweez's avatar
    Sweez
    Contributor

    In my case, the member formulas are for a complex variance calculation I have in a Finance assembly rule that is used in a cubview.  This cubeview is in turn used in a larger solution I am upgrading from using BRs to assemblies which is why i have this problem now.  I use to create an instance of the BR class in the member formula and then reference a function to return the value.  This kept the membe formual simple and allowed me to keep the much larger logic withing the solution, with the option to encrypt is as well.  

    • RobbSalzmann's avatar
      RobbSalzmann
      Valued Contributor II

      In this case I would probably keep it simple and move this logic to an assembly and run it via Data Management Seq/Step whenever the data affecting the variance gets changed.