cancel
Showing results for 
Search instead for 
Did you mean: 

Using standard substitution variables in Business Rules; Example: |CVYear|

chris_rothermel
New Contributor II

 

How can we reference substitution variables like |CVYear| in a Business Rule?  These variables are great for Cube Views, but now I'd like to access it directly in a Business Rule (custom calculate).

 

Dim ExampleCVYearDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula( "T#[CVYear]" )

Error processing Data Management Step 'Enrollment'. Unable to execute Business Rule 'zzzAdjRevenueDriverValue'. Invalid script 'T#[CVYear]' near 'CVYear'.

 

Dim ExampleCVYearDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula( "T#[|CVYear|]" )

Error processing Data Management Step 'Enrollment'. Unable to execute Business Rule 'zzzAdjRevenueDriverValue'. Invalid script 'T#[|CVYear|]' near '|CVYear|'.

 

At a minimum I'd like to know how to print the contents of the variable CVYear to the log.

api.LogMessage("Value of |CVYear| " & BRApi.Dashboards.Parameters.GetLiteralParameterValue(api.SI, True, "CVYear") )

api.LogMessage("Value of |CVYear| " & BRApi.Dashboards.Parameters.GetLiteralParameterValue(api.SI, True, "|CVYear|") )

Value of |CVYear| Unknown11/3/2022 12:24:56 PMInformationAdmin   

 

Appreciate any help on how to use these variables within Business Rules.

Thanks,

Chris

 

 

 

2 ACCEPTED SOLUTIONS

SamRichards
Contributor

Hey Chris,

How I would use something like |CVYear| or |WFYear| that is in the data unit in a custom calculate would be to use it in the Data unit section in the Data Managment job. Then in the rule all you need to do is use a api.pov.time.name call for example and you now know what year you are processing. If you want to use a variable that isn't in the data unit then you can pass it through in via parameters section in the Data Mangement job and say somthing like CVUD1=|CVUD1| then in the rule is it just the standard args.CustomCalculateArgs.NameValuePairs("CVUD1") to pull that through into the rule.
I will add I would be careful using say CVUD1 becuase if the CV doesn't have a UD1 defined it in then you run the risk that it will pull it from the Cube POV on the right and that could vary from user to user.

Thanks,

Sam

View solution in original post

chris_rothermel
New Contributor II

Hi Sam,

I do not want |CVYear| to be in the Data Unit portion of the Data Management Job.  I will want to compare the Data Unit Time to the variable |CVYear| and calculate depending on the comparison.

 

I like your idea of passing |CVYear| as a parameter, but it would be nice to access this standard variable directly in the business rule.  That give me something good to try -- I've not passed parameters in before.  Thank you!

 

Anyone have any thoughts on accessing the value of |CVYear|  directly in a business rule?

 

Thanks,

Chris

 

View solution in original post

5 REPLIES 5

SamRichards
Contributor

Hey Chris,

How I would use something like |CVYear| or |WFYear| that is in the data unit in a custom calculate would be to use it in the Data unit section in the Data Managment job. Then in the rule all you need to do is use a api.pov.time.name call for example and you now know what year you are processing. If you want to use a variable that isn't in the data unit then you can pass it through in via parameters section in the Data Mangement job and say somthing like CVUD1=|CVUD1| then in the rule is it just the standard args.CustomCalculateArgs.NameValuePairs("CVUD1") to pull that through into the rule.
I will add I would be careful using say CVUD1 becuase if the CV doesn't have a UD1 defined it in then you run the risk that it will pull it from the Cube POV on the right and that could vary from user to user.

Thanks,

Sam

chris_rothermel
New Contributor II

Hi Sam,

I do not want |CVYear| to be in the Data Unit portion of the Data Management Job.  I will want to compare the Data Unit Time to the variable |CVYear| and calculate depending on the comparison.

 

I like your idea of passing |CVYear| as a parameter, but it would be nice to access this standard variable directly in the business rule.  That give me something good to try -- I've not passed parameters in before.  Thank you!

 

Anyone have any thoughts on accessing the value of |CVYear|  directly in a business rule?

 

Thanks,

Chris

 

chris_rothermel
New Contributor II

Hi Sam,

Thanks for your help.  I added this parameter to the Custom Calculate Business Rule.

CVYear = |CVYear|

Then coded the BR to display it:  api.LogMessage("|CVYear| " & args.CustomCalculateArgs.NameValuePairs("CVYear") )

 

And I got the correct result:

Description: |CVYear| 2023
Error Time: 11/3/2022 6:14:30 PM
Error Level: Information
Tier: AppServer

 

I can move along today with the custom calculate.  But I won't be able to do this with a regular calculate function because that doesn't have parameters sent in.  😞  I'll create a new thread  on that.

 

Thanks,

Chris

 

Hey Chris,

 You are correct you can't pass a substitution variable like |CVYear| into a regular Calculate Finance BR because you don't have that option. There are ways around this like using a parameter instead of the variable and you can also have that parameter set a literal parameter inside of a dashboard to pull into a calculate but I would question the practice of referencing something like |CVYear| inside of a calculate because it doesn't seem like a great way to run because if you attach that BR to the cube to get it to run when you calculate a cube then it will run every time there is a calculation/consolidation done. 

db_pdx
Contributor III

Hi chris: when working in Finance Business Rules you have the POV context always available.  Thus, you can access the time simply via: api.Pov.Time    (with all of its various properties and methods).  There are also shortcuts available from api.Time (with many out-of-box functions for getting period numbers, prior periods, with no required inputs).