How-to: Xperiflow Business Rules in Legacy Business Rules
The purpose of this article is to demonstrate how to interact and leverage core Xperiflow Business Rule Services from outside a Solution.
Imagine you are on a SensibleAI Forecast engagement, and you need to pull back data that is stored in a .parquet file from the Xperiflow MetaFileSystem. What do you do? Well, in AI Services Solutions, you would just use the Dependency Injection container that exists in your Startup class. But, in a one-off OneStream Business Rule, that won’t work because you don’t have a Startup
class. You need a simple method to be able to access services like the IMetaFileSystemClient
within your Data Pipelines. This article is about showing you how to do that.
Background: Xperiflow Business Rules Inside a Solution
For perspective, Xperiflow Business Rules functionality is heavily used within many AI Services Solutions such as Xperiflow Utilities, SensibleAI Library, SensibleAI Forecast, etc. It is expected that Solution Developers register Xperiflow Business Rules services such as IMetaFileSystemClient
or IXperiflowClient
with a Microsoft.DependencyInjection
container at the Startup
entrypoint of the Solution’s Assembly.
However, it is important to note that the Dependency Injection design pattern used in Solutions cannot be used inside of freeform OneStream Business Rules due to how the Dependency Injection container is managed and registered in a Solution. The same environment doesn’t exist in standard OneStream Business Rules. Therefore, there is an alternative means of interacting with Xperiflow Business Rules services like IMetaFileSystemClient
within standard OneStream Business Rules.
Solution: Leverage the Xperiflow Business Rules XBRApi
Leverage the XBRApi module found within Xperiflow Business Rules and directly reference Xperiflow Business Rules from within your Business Rule.
Xperiflow Business Rule XBRApi
are essentially a set of factories that simplify the creation of Xperiflow Business Rules services so that a dependency injection container is not needed to leverage the services.
How to: Leverage XBR in Legacy OneStream Business Rules
OneStream Legacy Business Rules means accessing business rules via Application → Business Rules. This is considered the old methodology and it is preferred to use OneStream Workspaces moving forward.
It is recommended that you use OneStream Workspace moving forward.
Step 1: Ensure Xperiflow Business Rules is Installed
Step 2: Create a OneStream Business Rule
Let’s create a OneStream Business Rule by navigating to Application → Business Rules → Create Business Rule.
Let’s create a name for our Business Rule. In my case, we are just naming it XBR_Tester
since we are not meaning to do anything that meaningful here.
Step 3: Register the Workspace Reference
After we created our XBR_Tester
Extender Rule (This will show up under Extensibility Rules), the next step is to register our Xperiflow Business Rules Assembly as a reference to our XBR_Tester
.
We can register the Xperiflow Business Rules XBR
assembly by typing WS\Workspace.XBR.Xperiflow
into the Referenced Assemblies field.
If you hover your cursor over the Referenced Assemblies, we can see the other options we have to reference other types of Assemblies
Step 4: Import Any Xperiflow Business Rule Namespace in the Code
We can quickly validate that our Referenced Assemblies field was filled out properly by dropping in a using statement into our Business Rule.
Below are some of the common imports you will likely want from XBR
:
using Workspace.XBR.Xperiflow; // XBRApi
using Workspace.XBR.Xperiflow.Core.Session;
using Workspace.XBR.Xperiflow.Utilities.AdoDataTable.Extensions; // DataTable Extensions
using Workspace.XBR.Xperiflow.MetaDB; // Query tabular files from the AI Data Lakehouse using DuckDB syntax fro
using Workspace.XBR.Xperiflow.MetaFileSystem; // Pull back files from the AI Data Lakehouse
using Workspace.XBR.Xperiflow.Routines; // Routine objects
using Workspace.XBR.Xperiflow.Routines.Instances; // Routine instance objects
using Workspace.XBR.Xperiflow.Routines.Runs; // Routine Run objects
using Workspace.XBR.Xperiflow.Routines.Artifacts; // Routine Artifact objects
using Workspace.XBR.Xperiflow.Utilities.Logging.Extensions; // BRApi Logging Extensions
and then we hit the compile button, we can quickly check whether or not we properly filled out our Referenced Assemblies.
Step 5: Start Writing Code!
At this point, we can start writing code and referencing any of the code found in Xperiflow Business Rules Assembly XBR
.