Skip to main content

Using BRApi vs Api

Using BRApi vs Api

BRApis are a versatile Class used across all Business Rules (BR) / Service Types, engines, and APIs in OneStream with purposeful functions. While not an engine, BRApis enables communication and function orchestration across engines and APIs.

  • A common use of BRApi is to source data from an external data source utilizing a Connector BR.

An API is specific to the executing engine, such as the Finance Engine, and provides functions specific to the type of Business Rule / Service Type being written.

  • For example, Finance Engine API functions are designed to facilitate multi-dimensional “cube” calculations and enable complex financial data analysis and processing.

When an API can be implemented, use the API instead of the equivalent BRApi, as the BRApi opens a connection to the application, whereas the API does not. For additional information related to the Finance Engine, please refer to the Finance Usage Guide.

Code Examples

case var @case when @case == FinanceFunctionType.Calculate:
{

// Base Entities - all C#'s if they have data
// Parent Entities - all C#'s EXCEPT Local (no parent adjustments)
if (!(api.Entity.HasChildren() && api.Cons.IsLocalCurrencyForEntity()))
{

#region Clear Plug Accounts

// If the Cons member is Elimination
if (api.Pov.Cons.MemberId == DimConstants.Elimination)
{

var plugAccountList = new List<string>();
string plugAcctName = string.Empty;

// Get a list of all base Account members
List<Member> balSheetBaseAcctList = api.Members.GetBaseMembers(api.Pov.AccountDim.DimPk, api.Members.GetMemberId(DimType.Account.Id, "BalanceSheet"));

// Loop over all base Accounts and if they have a Plug Account assigned, add that Plug Account to the list
foreach (Member baseAcct in balSheetBaseAcctList)
{

plugAcctName = api.Account.GetPlugAccount(baseAcct.MemberId).Name;

if (!string.IsNullOrWhiteSpace(plugAcctName) && plugAccountList.Contains(plugAcctName) == false)
{
plugAccountList.Add(plugAcctName);
}

} // baseAcct

// Clear the Plug Accounts when they have data with the CF UD6 members
api.Data.ClearCalculatedData(true, true, true, true, "A#" + string.Join(",A#", plugAccountList.Distinct()), default, default, default, default, default, default, default, default, "U6#Total_CF.Base");

}
}
}
namespace Workspace.__WsNamespacePrefix.__WsAssemblyName
{
public class svcFinanceCore : IWsasFinanceCoreV800
{
public void Calculate(SessionInfo si, BRGlobals brGlobals, FinanceRulesApi api, FinanceRulesArgs args)
{
try
{
// Base Entities - all C#'s if they have data
// Parent Entities - all C#'s EXCEPT Local (no parent adjustments)
if (!(api.Entity.HasChildren() && api.Cons.IsLocalCurrencyForEntity()))
{

#region Clear Plug Accounts

#region Calculate CF

} // If (Not (api.Entity.HasChildren() AndAlso api.Cons.IsLocalCurrencyForEntity())) Then

}
catch (Exception ex)
{
throw new XFException(si, ex);
}
}
// 3. Get the Drill Back Type (Options)
// If the user is a member of group, TechTalkDrillBack, or in the Administrators group, Drill Back is enabled
case var case2 when case2 == ConnectorActionTypes.GetDrillBackTypes:
{
if (BRApi.Security.Authorization.IsUserInGroup(si, si.UserName, "TechTalkDrillBack", true))
{
switch (true)
{
// Define Drill Back Types (Options) presented to the end user when Drill Back occurs
case object _ when strDataSourceName.XFEqualsIgnoreCase("HoustonRevMgmt"):
{
return getDrillBackTypeList(si, globals, api, args);
}
}
}
else
{
return null;
}

break;
}

Was this page helpful?