Cube Views - Calling XFBR Rules w/in a XFBR Rule

BryanMulder
New Contributor II

Hi All,

I'm trying to call out a XFBR string w/in a XFBR string in the column set of my CV (snip below).  Our consultant initially setup the first XFBR so that we could report on completed weeks of the month while rendering zero for the future weeks.  The logic works great but is dependent on manually entered parameters.  This is when I tried to introduce the second XFBR string to dynamically determine the prior week so that we can automate distribution of this output.  After pushing in the second XFBR string I get an error when running the CV of, 'Input string was not in a correct format' (see second snip).  I've tried to pass in the week value as an integer, a string, and as an Int32 value but nothing has worked yet.  I've also tried with and without the brackets [ ] on the CV column set, but no luck.  Any suggestions out there?  Help would be greatly appreciated.

Thanks,

Bryan 

 

BryanMulder_0-1640095351657.png

BryanMulder_1-1640097013592.png

 

 

3 REPLIES 3

ChristianW
Valued Contributor

Embedded xfbrs within a xfbrs would be a nice, but in your case, it isn't needed, why don't you just combine the two function? You can call the inner function first to get the week and then you can call the second function with the information from the first? Both functions seam to be in the same business rule UFP_XFBRString).

I don't have your code, but you probably will find something like this in UFP_XFBRString:

Attention, this is a none working snippet

Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardStringFunctionArgs) As Object
	Try
	
....

		If args.FunctionName.XFEqualsIgnoreCase("GetPWeek") Then
			Return GetPWeek(...)
		End If
....
		If args.FunctionName.XFEqualsIgnoreCase("NextWeeksInMonth") Then
			Dim year As String = args.NameValuePairs("curYear")
			Dim week As String = args.NameValuePairs("curWeek")

			Return NextWeeksInMonth(..., year, week)
		End If

...

		Return Nothing
	Catch ex As Exception
		Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
	End Try
End Function

 

If this is the case, you can simple create a version like this:

Attention, this is a none working snippet

Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardStringFunctionArgs) As Object
	Try
	
....

		If args.FunctionName.XFEqualsIgnoreCase("GetPWeek") Then
			Return GetPWeek(...)
		End If
....
		If args.FunctionName.XFEqualsIgnoreCase("NextWeeksInMonth") Then
			Dim year As String = args.NameValuePairs("curYear")
			Dim week As String = args.NameValuePairs("curWeek")
			if week = "GetPWeek" then
				week = GetPWeek(...)
			end if

			Return NextWeeksInMonth(..., year, week)
		End If

...

		Return Nothing
	Catch ex As Exception
		Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
	End Try
End Function

that should do the job if you call:

xfbr(UFP_XFBRString, NextWeeksInMonth, curYear=[|WfYear|], curWeek=GetPWeek)

I hope this gives you an idea how to solve the problem. Please only do it this way, when the BR is a custom business rule and nothing from the market place. When working with functions from MarketPlace solutions, we have other possibilities to solve similar problems.

BryanMulder
New Contributor II

Appreciate the reply Christian!  I'm not the most versed in creating BR's but I'll give this a shot.  

I am ultimately attempting to send this CV out via the Parcel Service, so maybe I'm overlooking an easier solution on that front?  I know we can pass parameters in on the packages, would that be as simple as this parameter, 'curWeek=GetPWeek'?   Thanks again for the help!  

ChristianW
Valued Contributor

In case you can't do it on your own, send me the full BR as message and I can have a look at it.

Cheers

Christian