Accessing predefined substitution variables in Business Rules

jesvam
New Contributor III

Hi, I can't seem to find a method in the api that accepts a substitutionvariable object and returns the string value of that substitution variable. Or just get a dictionary of all predefined substitution variables and their values. 

Is this or something similar available? 

1 ACCEPTED SOLUTION

JackLacava
Community Manager
Community Manager

Do it in an XFBR, there you have everything you need in args.SubstVarSourceInfo.

View solution in original post

7 REPLIES 7

ChristianW
Valued Contributor

If you use the dashboard extender business rule, you will find the information here:

ChristianW_0-1691585012722.png

 

jesvam
New Contributor III

Thanks, but I don't believe this is for the predefined ones.

JackLacava
Community Manager
Community Manager

Do it in an XFBR, there you have everything you need in args.SubstVarSourceInfo.

jesvam
New Contributor III

Thank you Jack, that is super useful! I also managed to find what I wanted based on that object you provided in the api details. Pasting a snippet below for anyone reading. 

Unfortunately it didn't contain what I was searching for now. I was hoping a dynamic calc could somehow pull cube view substitution variables from the cube view it is calculated in, but seems that it is not the case.

Dim instance As New SubstVarSourceInfoFactory
Dim dbConnFW As DbConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
Dim dbConnAppOrFW As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
Dim isSystemLevel As Boolean = False
Dim value As SubstVarSourceInfo
value = instance.GetOrCreateSubstVarSourceInfo(dbConnFW, dbConnAppOrFW, isSystemLevel)

JackLacava
Community Manager
Community Manager

If you're doing a Dynamic Calc, what you could do is actually using a custom GetDataCell function. This way, you don't need to worry about resolving expansions yourself - you just pass the variables you need as arguments.

This is a woefully undocumented corner of the platform, but it's actually quite cool. In a Finance BR (called "MyFinanceBR" in this case), use the relevant FinanceFunctionType block:

 

Case Is = FinanceFunctionType.DataCell
	If args.DataCellArgs.FunctionName.XFEqualsIgnoreCase("MyFunction") Then
		api.LogMessage(args.DataCellArgs.NameValuePairs.Keys(0))
		api.LogMessage(args.DataCellArgs.NameValuePairs.Values(0))
		Return 1  
	End If

 

Then in your CubeView, use the expanded syntax (sadly it doesn't seem to work with the condensed one)

JackLacava_1-1691671963343.png

Result:

JackLacava_2-1691672028509.png

note how I had to put square brackets around my variable, that's because otherwise spaces and special chars will wreak havoc on the expansion.

In terms of performance, I *think* this strategy might be a bit faster than opening db connections in XFBRs, but I could be wildly wrong.

jesvam
New Contributor III

Thanks! But with a data cell BR you wouldn't be able to return a text value right, it only returns numeric values?

I was hoping to dynamically determine the text value that the cell would return based on the cvname for example. 

JackLacava
Community Manager
Community Manager

Depends on the View member. Annotation-type views (Annotation, Footnote, etc) support text, so as long as you set the row or column to that you can return text.