Workspace assemblies - Call functions from another file within the same assembly

MarkMeader
New Contributor III

Hi

I'm trying to find out the correct way to reference a function in another Workspace assemblies file.

For example say i have:

1) XFBR business rule assembly file (ParamHelper.Vb)
2) Dashboard Extender business rule assembly file (SolutionHelper.Vb)

I want to call a function that is in SolutionHelper.vb  from my code that sits in ParamHelper.vb

In standard business rules this was easily achieved using Referenced Assemblies in the business rule property 

Assemblies2.png

and then adding something along the lines of this below: 
Dim _MYHelper As New OneStream.BusinessRule.DashboardExtender.HPB_SolutionHelper.MainClass

Just not sure how the same is achieved using assembliesAssemblies.png

 

Thank you

2 ACCEPTED SOLUTIONS

ChristianW
Valued Contributor

In version 8, most of the business rules will be located in the same namespace

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName

So to access classes within this namespace, just add

Imports Workspace.__WsNamespacePrefix.__WsAssemblyName

to the business rules / files that are not in this namespace

For example:

...
Imports Workspace.__WsNamespacePrefix.__WsAssemblyName

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName.BusinessRule.DashboardExtender.SolutionHelper
	Public Class MainClass
...

This works as well in 7.4.x

So for all files, that are not of dashboard data set, dashboard extender, dashboard xfbr sting or Spreadsheet, business rules equivalent use this namespace.

View solution in original post

To save a bit of typing, one can import the whole namespace. For example, assuming you have a class "SomeCustomClass" defined in a DDS called "MyBR":

Imports Workspace.__WsNamespacePrefix.__WsAssemblyName.BusinessRule.DashboardDataSet.MyBR

...

Dim myObj as SomeCustomClass = new SomeCustomClass

 

View solution in original post

11 REPLIES 11

ChristianW
Valued Contributor

In version 8, most of the business rules will be located in the same namespace

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName

So to access classes within this namespace, just add

Imports Workspace.__WsNamespacePrefix.__WsAssemblyName

to the business rules / files that are not in this namespace

For example:

...
Imports Workspace.__WsNamespacePrefix.__WsAssemblyName

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName.BusinessRule.DashboardExtender.SolutionHelper
	Public Class MainClass
...

This works as well in 7.4.x

So for all files, that are not of dashboard data set, dashboard extender, dashboard xfbr sting or Spreadsheet, business rules equivalent use this namespace.

Excellent thank you Christian. Makes sense to me so i will give that a try

For example, if you have a file for the class EntityList

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName
	Public Class EntityList
...
	End Class
End Namespace

you can do this

...
Imports Workspace.__WsNamespacePrefix.__WsAssemblyName

Namespace Workspace.__WsNamespacePrefix.__WsAssemblyName.BusinessRule.DashboardExtender.SolutionHelper
	Public Class MainClass
		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardExtenderArgs) As Object
			Try
				Dim EntLstHelper As New EntityList()
...

 

Edit: My mistake, I thought the OP wanted to call a traditional DashboardExtender BR, and I see now he is wanting to reference on Assembly from another.

@ChristianW where is this documented for 7.4.x?  I tried several times to get this to work.  It never occurred to me nor did I find anything to direct me to use the tokens __WsNamespacePrefix and __WsAssemblyName

RobbSalzmann_0-1696002029872.png

 

It is based on some external documentation about namespaces and Information in the 8.0 documentation, introducing a new concept called service factory.

I had to downgrade an application and found, that I could call the files from the old business rules equivalents.

With service factory, we don't need different namespaces for different use cases anymore, it will all stay in the same namespace.

Workspace.__WsNamespacePrefix.__WsAssemblyName

Except you like to change it for other reasons.

To save a bit of typing, one can import the whole namespace. For example, assuming you have a class "SomeCustomClass" defined in a DDS called "MyBR":

Imports Workspace.__WsNamespacePrefix.__WsAssemblyName.BusinessRule.DashboardDataSet.MyBR

...

Dim myObj as SomeCustomClass = new SomeCustomClass

 

RobbSalzmann
Valued Contributor

The OneStream.BusinessRule Namespace is not in scope in Referenced Assemblies.  To my knowledge, it won't work to reference standard business rules from a Dashboard Assembly.

RobbSalzmann_1-1696000763436.png

 

Thanks for commenting and although this wasnt what i was looking for i thought i would share with you as you may find it useful because It is actually possible to reference a business rule from a dashboard assembly.

1) Create a dependency with a BR type "Business Rule" and enter the name of the business rule

BR.png

2)  Create a new Object to the BR class in the assembly rule eg
Dim _HPBHelper As New OneStream.BusinessRule.DashboardExtender.HPB_SolutionHelper.MainClass

Note: Intellisense will not show it as being an option but it does still work

br2.png

 

This must be V8?  I don't see the choice to reference a BR in the 7.xx versions

RobbSalzmann_0-1696251396994.png

 

Ah yes must have been an enhancement for v8

MarkMeader
New Contributor III

Thank you Christian and Jack. 
Seems very obvious now and really i just needed to get my head into thinking of this more as a project in visual studio with namespaces than regular business rules.