Business Rule Compile Error and Warnings
OneStream Platform releases will periodically include an update to the Business Rules compiler, which is noted in each version’s Release Notes. The enhancements typically make the compiler stricter in detecting syntax or other conditions, which are surfaced through Error or Warning messages. Error messages must be resolved, as the Business Rules will not complete the compile process. Warning messages are exposed to provide guidance to the Administrator. The displayed line items will still function but should be updated to support the latest compiler’s requirements. The method to resolve the Warning will vary. In some cases, a replacement function may be available, or there may be a change to a function’s properties. Example The above error message informs the Administrator of a Warning on the LookupRowFieldValue function having a property change. By reviewing the current rule, and by looking at the current Function Definition, the Administrator can determine that the property for “Criteria as a String” has been modified. The current Definition now defines the field as a dbWhere object. Old Properties LookupRowFieldValue(ByVal si As SessionInfo, ByVal dbLocation As String, ByVal tableName As String, ByVal criteriaExpression As String, ByVal fieldToReturn As String, ByVal defaultValue As String) As String To correct the condition, the Administrator is required to apply the required change. In this example, a dbWhere object must be used to define the criteria against the target database table. New Properties LookupRowFieldValue(ByVal si As SessionInfo, ByVal dbLocation As String, ByVal tableName As String, ByVal dbWheres As List(Of DbWhere), ByVal fieldToReturn As String, ByVal defaultValue As String) As String Other Compile Issues - Namespaces The Vb.Net language in OneStream offers the designer flexibility to implement custom solutions using predefined libraries as well other compatible third-party libraries. During a Business Rules compile, there are NameSpaces in OneStream that will be implicitly compiled: microsoft.visualbasic system.linq system.collections.generic system.collections system.text OneStream also has predefined Namespaces in Business Rules, which if utilized, must not be removed from the rule to compile properly. Imports System Imports System.Data Imports System.Data.Common Imports System.IO Imports System.Collections.Generic Imports System.Globalization Imports System.Linq Imports Microsoft.VisualBasic Imports System.Windows.Forms Imports OneStream.Shared.Common Imports OneStream.Shared.Wcf Imports OneStream.Shared.Engine Imports OneStream.Shared.Database Imports OneStream.Stage.Engine Imports OneStream.Stage.Database Imports OneStream.Finance.Engine Imports OneStream.Finance.Database The solution to resolving a Namespace issue will depend upon whether the rule exists in a Member Formula or as part of a Business Rule file. When an unsupported Namespace is used in a Business Rule file, the Namespace can be added to the Imports to allow the Business Rules to compile. Member Formulas do not allow access to modify the Import section of Business Rules. If the unsupported Namespace is part of a Member Formula, then the full Namespace must be added to the affected expression or variable.2.1KViews7likes0CommentsRules Formatting - Please Format Your Rules!!
General Formatting One of the most important things you can do, to make you rules readable and helpful, is making sure they are properly formatted. There are some simple rules you should probably follow all the time: Proper Case – Function names are not case-sensitive; for example, api.data.calculate, Api.Data.Calculate, or API.DATA.CALCULATE, are treated as the same. Still, it is a best practice of VB style to be consistent and to capitalize judiciously. Proper case throughout the rules file makes it much easier to read. Always Comment – Add comments to most lines of code explaining what you are doing and why. Use the apostrophe at the beginning of the comment to make sure it is not interpreted as part of the rules. If this is done in a VB editor, it should turn green by default. Indentation is critical for readability – This is especially true when using any nested statements or conditionals. Those are explained below. Indentation should be done for any scripting, even scripting objects in Business Rules Editor. Variable and Constants properly named – All variables should be given useful names. Line Continuations Properly formatting rules will typically also mean using the underscore ‘_’ and colon ‘:’ symbols. When using space + underscore, you are telling the script that the command continues on the next line. For example: api.data.Calculate("F#[Bad Debt]:A#[EBITDAVar] = " & _ "(A#54100:S#Budget:F#None-A#54100:S#Actual:F#None)") The colon allows you to combine two lines. For example: strSalesAccount = “A#7999.UD1#Sales” : strMktAccount = “A#7999.UD1#Marketing” Comments I think it is important to emphasize the importance of comments. You will not remember in a year or two why something is quite the way it is, so comments will help you from making the same mistake again. It can help provide a new administrator detailed information, such as what needs updating or regular maintenance, if you add a new cash flow account for example. Finally it can help remind you what needs to be considered for an upgrade, or rebuild. Variables & Constants Variables and constants are used to hold values or expressions. Think back to your 9th grade algebra class. In 2+y = x, y is the variable. (See, your teacher was right, this may prove useful yet...) Variables can have any name; but while ‘y’ and ‘x’ are valid names, they don't tell you anything. Names should be something that makes sense. Consider which of the following is easier to follow: 2 + y = x or 2 + strVariablePercent = strPercentMarkUp. I would say you can understand more form the second line of rules than the first, even without knowing the context. Add a line of comments, and note the proper case, and you are on your way to well formatted descriptive rules. A Variable is a value that changes depending on parameters and when it is used; whereas a Constant will not change, regardless of when it is used or changes in the application. You will want to declare constants at the beginning of rules files. They can be available to all procedures at all times. Apart from that, they are used just like variables. You should have some guidelines when writing rules; one of the simplest things to do, to keep yourself organized, is to have a naming convention. I like to use a prefix. The prefix is something that helps me remember what is in the variable. I might use ‘str’ or ‘s’ for a string, or ‘bln’ or ‘b’ for a Boolean (true or false), and ‘nbr’ or ‘n’ for number. Then using proper case I use a descriptive label for my variable. So, for a number from Net Income, my variable might be called ‘nbrNetIncome’. I can see that variable name anywhere in my file and know what the variable is for and what it is. Compare that with ‘x’; if I just see x, who knows what it is for. It also helps to know what you are going to use the variable for. We have two names for variables; Replacement Variables and Execution Variables. Replacement Variables are typically used for constants like static strings (for example topUD1=“.UD1#TopUserDefined1”). This variable might change, but it is replacing some part of a string. Execution Variables are typically used for situations in which variable is populated or reset during some condition or rule (for example sPOVEntity = api.POV.Entity.Name). The point of view changes constantly and what would be written in the variable would be updated accordingly. There are some rules for variable names that you just must follow, to write valid VB.Net. They must always begin with a letter. They cannot contain a period. You should avoid keywords such as “OneStream”, “Entity”, “Account”, when naming variables; they tend to be reserved by OneStream and could cause problems if shadowed. VB.Net requires you to declare variables before using them. Since variables will require what type they can hold, you need to make sure you avoid letting the variable use a type that Rules Engine is not expecting for that member. For example, if you write a rule checking if the year is 2010, OneStream could see that as something different than “2010”. By using the quotes and declaring it As String, the number 2010 becomes a String of text, “2010”. Otherwise you might get a Type Mismatch error in some situations; if you do get this error, double check that the variable you are testing is correctly declared.2.5KViews4likes2Comments[howto] Use "Insert Code" when posting on Forum boards
Hey guys! Just a reminder: if you're going to post code in this forum, please make it easier to read by using the "Insert/Edit Code Sample" button on the expanded formatting toolbar. Here's a short video showing how it works. If you need to edit code after you created the block, just double-click on it. Ideally you'd also indent it first, either in an editor or with something like DotNetFiddle. Remember: the easier it is for others to read your code, the more likely that they'll be able to solve your problem! Cheers! Your friendly neighborhood Spider-Mod3KViews4likes6CommentsDashboard: XFBR String
Business rules written and used as Parameters that return a specific value based on the defined inputs. This Business Rule can be applied to any Dashboard or Cube View property where a Parameter is used. Imports System Imports System.Data Imports System.Data.Common Imports System.IO Imports System.Collections.Generic Imports System.Globalization Imports System.Linq Imports Microsoft.VisualBasic Imports System.Windows.Forms Imports OneStream.Shared.Common Imports OneStream.Shared.Wcf Imports OneStream.Shared.Engine Imports OneStream.Shared.Database Imports OneStream.Stage.Engine Imports OneStream.Stage.Database Imports OneStream.Finance.Engine Imports OneStream.Finance.Database Namespace OneStream.BusinessRule.DashboardStringFunction.XFBRStringExamples Public Class MainClass Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardStringFunctionArgs) As Object '------------------------------------------------------------------------------------------------------------ 'Reference Code: GetCalcStatus ' 'Usage: This shows different examples of BRString usage in Cube Views and Dashboards ' 'GetCalcStatus ' Parameter Example: ' BRString(XFBRStringExamples, GetCalcStatus, ParamCube = GolfStream, ' ParamEntity = [Houston Heights], ParamParent = Houston, ' ParamCons = USD, ParamScenario = Actual, ParamPeriod = 2011M1) ' 'GetUserIsAdmin ' Parameter Example: BRString(XFBRStringExamples, GetUserIsAdmin) ' 'EntityDesc ' Parameter Example: BRString(XFBRStringExamples, EntityDesc, ParamEntity=[|!MyEntity!|]) ' 'Created By: OneStream 'Date Created: 12-18-2017 '------------------------------------------------------------------------------------------------------------ Try Select Case args.FunctionName Case Is = "GetCalcStatus" 'Get the Passed in parameters Dim paramCubeValue As String = args.NameValuePairs("ParamCube") Dim paramEntityValue As String = args.NameValuePairs("ParamEntity") Dim paramParentValue As String = args.NameValuePairs("ParamParent") Dim paramConsValue As String = args.NameValuePairs("ParamCons") Dim paramScenarioValue As String = args.NameValuePairs("ParamScenario") Dim paramPeriodValue As String = args.NameValuePairs("ParamPeriod") Return BRApi.Finance.Data.GetCalcStatus(si, _ paramCubeValue, paramEntityValue, paramParentValue, _ paramConsValue, paramScenarioValue, paramPeriodValue) Case Is = "GetUserIsAdmin" 'Check to see if the user is an administrator ' (Can be used to hide objects that are administrator only) Return BRApi.Security.Authorization.IsUserInAdminGroup(si) Case Is = "EntityDesc" 'Get the Passed in parameter Dim myEntity As String = args.NameValuePairs("ParamEntity") Dim myEntityDesc As String = BRApi.Finance.Metadata.GetMember( _ si, 0, myEntity).Member.Description Return myEntityDesc End Select Return Nothing Catch ex As Exception Throw ErrorHandler.LogWrite(si, New XFException(si, ex)) End Try End Function End Class End Namespace3.4KViews2likes0CommentsRunning DM package from the BR and completing the workflow step
I would like to give my users the ability to launch the DM sequence from the workflow step. I have the dashboard with the button that passes the parameters to the DM package and launches the package. The last step in the DM sequence runs the Extensibility BR that completes the workflow step. Everything seems to work except that the workflow step window does not refresh after the sequence completion. The workflow step appears incomplete even though it is. The click on the "refresh Application" icon is required. Is there a way to address it? My Extensible BR is below:Solved3.8KViews2likes15CommentsAutomation for IIS Reset
Hey folks, Just wondering if we can automate IIS reset in the task scheduler. I don't see any Snippets or related BRApis in the Extensibility Business Rules. Surfed through various Community posts but, didn't help much. Any guidance here will be helpful.Solved1.7KViews1like2CommentsDashboard XFBR String Rules - api.data.GetDataCell
We want to make some forecast periods read only ( Data seeded periods from Actuals) in a Data submission cube view by referencing the period count submitted in another Cube View. Basically, this is to deal forecast data submission. Trying to achieve this by Dashboard XFBR string and that string is referenced into the Form template -> CubeView to make certain periods as readonly, so that they cannot submit the forecast data for those periods. Below is the script that we are using the get the Period count submitted in a specific POV( to start with, hard coded all the POV members) ---------------------------------------------------- Dim strActMonths As String = api.data.GetDataCell("E#FC_Seed_Entry:P#:C#Local:S#FC11:T#2023M12:V#Periodic:A#FC_Seeding:F#None:O#Forms:I#None:U1#None:U2#None:U3#None:U4#None:U5#Text3:U6#None:U7#None:U8#None").CellAmount Dim iActMonths As Decimal = 0 iActMonths = strActMonths.XFConvertToInt ---------------------------------------------------- We have called this into a Form tempplate and then to CubeView to display the columns. But, when we try to open the Cube View it's giving the error " Object variable or With block variable not set" It looks like there is some gap in pulling the POV value and converting to integer. Appreciate your thoughts on this. If we hardcode the iActMonths value to certain number as below, it's working as expected. "Dim iActMonths As Decimal = 5" also, the same logic is working fine in Finance rules section to seed the data from Actuals, But not in the DashBoard XFBR type. Appreciate your thoughts on this. BSK2.4KViews1like6CommentsWeekly scenario - Use scenario start/end period settings
Hi community, For one of our clients we are looking for the following. - We create 52 weekly scenario with each their own start and end period setting in the workflow start time and workflow end time. For example we have the scenario CFF_2022W01 which has a workflow start time as 2022W1 and a workflow end time as 2022 W39. For example the scenario CFF_2022W02which has a workflow start time as 2022W2 and a workflow end time as 2022 W39 etc. How can we get a list of members of the range within the start and end time in the scenario. So for example based on the CFF_2022W01 scenario it should return in the list 2022W1, 2022W2 up until 2022W39. For CFF_2022W02 it should return in a list 2022W2, 2022W3 up until 2022W39. There is also the example when the periods run across years. So for example the scenario CFF_2022W27 has a workflow start time of 2022W27 and end time of 2023W13. The list should then return 2022W27, 2022W28 up until 2022W52 plus also 2023W1 up until 2023W13. This is what I used so far but is not working correctly for weeks. --- Dim instance As New BRApiFinanceScenario() Dim ScenarioStartPeriod As Integer = instance.GetWorkflowStartTime(si, ScenarioId) Dim ScenarioEndPeriod As Integer = instance.GetWorkflowEndTime(si, ScenarioId) Dim noOfNoInput As Integer = instance.GetWorkflowNumNoInputTimePeriods(si, ScenarioId) Dim ScenarioPeriods As List(Of Integer) = TimeDimHelper.GetIdsInRange(ScenarioStartPeriod, ScenarioEndPeriod) 'Removes all periods up until the input range ScenarioPeriods.RemoveRange(0, noOfNoInput) ----- Has anyone come across using these settings and what syntax should be used.1.2KViews1like2CommentsLock dashboard to other users
Hi all, I'm developing a dashboard that will likely be used by 10 different people. I'd like to lock the access to other users if one user has the dashboard already open (and maybe until he/she clicks on a button to unlock it?) Does anyone have a reliable approach to do this? Thanks in advance!Solved1.9KViews1like3Comments