Forum Discussion

Brooks's avatar
Brooks
New Contributor III
1 day ago

Pull in Variables from another BR

I'm trying to call a helper BR that I wrote to pull in two variables to denote our environment, but I'm getting an error message saying the extender business rule.MainClass is undefined.

Background: Our GL has three environments, Dev, Prj (test) and PRD.  As we promoted projects up in OneStream, I have to edit the BRs to reference the different environments.  It's a pain when it comes to the SQL because the environment is part of the tableName.fieldName.

Goal: to have one helper BR that has the environment variables in it and all other BRs reference this rule so I no longer need to edit them from environment to environment.  The helper rule in DEV would reference the DEV tables, the helper in PRD would reference the production tables, etc.

'test code to pull in environment variables from a Helper 03-05-2026
				'Define reference to business rule
                   Dim JDE_EnvironmentHelper As New OneStream.BusinessRule.Extender.JDE_EnvironmentHelper.MainClass       '<-- Update ReferencedBRName with your Business Rule
                      
                   'Call function within referenced business rule
                   If Not JDE_EnvironmentHelper Is Nothing Then
                       Dim returnVariable As String = JDE_EnvironmentHelper.GetConnectionString(si, gateWay, envTbl) '<-- Update ReferencedBRFunctionName, param1..paramX, returnVariable type
                   End If			
' End test code 03-05-2026

The above code* is from the Connector rule that is to receive the variables, gateWay and envTbl.  The error I get when I validate it is:

  1. Error at line 37: Type 'OneStream.BusinessRule.Extender.JDE_EnvironmentHelper.MainClass' is not defined.

This code is directly copied from the OneStream snippets (modified for my BR name, of course)

What am I doing wrong?  Am I even on the right track?

 

*line 3 above is line 37 in my BR

2 Replies

  • Brooks's avatar
    Brooks
    New Contributor III

    Update.  I've solved the problem of not being defined, but run into a new problem.  In order for the called rule to be defined, I need to specify it in the receiving rule's properties.  Done.  Now I'm getting the error in the attached image.  This is in the Connector rule which is the receiving rule.

    But the code from my helper BR --which is an Extensibility rule-- validates just fine.

    Namespace OneStream.BusinessRule.Extender.JDE_EnvironmentHelper
    	Public Class MainClass
    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
    			Try
    			
                   'get the Connection String - function below
    				Dim connectionString As String = GetConnectionString(si, globals, api)
    				Return Nothing
    			Catch ex As Exception
    				Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    			End Try
    		End Function
    		
    #Region "Connection String Name"		   'Create a Connection string to the External Database
    	Private Function GetConnectionString(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Transformer) As String
    	    Try
    	 
    		Dim gateWay As String = "JDE_DEV_Gateway"		'Dev connection pointing to DEV
    		'Dim gateWay As String = "JDE_Proj_Gateway"        'Dev connection pointing to PROJ
    		'Dim gateWay As String = "JDE_Data_Gateway"		'Prod connection pointing to PROD
    		
    		Dim envTbl As String = "crp"  'DEV
    		'Dim envTbl As String = "proj" 'PRJ
    		'Dim envTbl As String = "prod" 'PRD
    		
    	    Catch ex As Exception
    	        Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
    	    End Try   
    	End Function 
    #End Region		
    		
    	End Class
    End Namespace
    

    How do I get my connector to recognize this as part of the Main class OR, what do I use in my helper instead of GetConnectionString to create my private function?  I've been struggling to figure out what else to use that would be part of Main class.  As you may have guessed by now, by VB skills are rudimentary.


    • rhankey's avatar
      rhankey
      Contributor III

      The external variable or function you are calling needs to be Public if it is to be seen outside the logic file.  In other words, you need to change GetConnectionString() to be Public.