Display Text1 member property instead of name or description in cubeview

AlvaroSR
New Contributor II

My client has member property Text1 in UD1 as a second description or alias, he wants to display Text1 instead of name or description. I tried with CV Function "u1#top.descendants.where(Text1 <> '')", but It is not working because keep appearing name or description.

Any recommendation with function CV or XFBR please?

Thanks.

1 ACCEPTED SOLUTION

TheJonG
Contributor III

You can use an XFBR rule. See script below. The member filter in the CV would be:

u1#top.descendants.where(Text1 <> ''"):Name(XFBR(XFBR_Example, GetTextFieldForDescription, UD1Member = |MFUD1|))

XFBR Rule:

 

Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine

Namespace OneStream.BusinessRule.DashboardStringFunction.XFBR_Example
	Public Class MainClass
		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("GetTextFieldForDescription") Then
					
					Dim ud1Member As String = args.NameValuePairs.XFGetValue("UD1Member","None")
					Dim ud1MemberID As Integer = BRApi.Finance.Members.GetMemberId(si, dimTypeId.UD1, ud1Member)
					Dim ud1TextField As String = BRApi.Finance.UD.Text(si, dimTypeId.UD1, ud1MemberID, 1,Nothing,Nothing)
					
					Return ud1TextField
				End If

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

 

View solution in original post

5 REPLIES 5

TheJonG
Contributor III

You can use an XFBR rule. See script below. The member filter in the CV would be:

u1#top.descendants.where(Text1 <> ''"):Name(XFBR(XFBR_Example, GetTextFieldForDescription, UD1Member = |MFUD1|))

XFBR Rule:

 

Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine

Namespace OneStream.BusinessRule.DashboardStringFunction.XFBR_Example
	Public Class MainClass
		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("GetTextFieldForDescription") Then
					
					Dim ud1Member As String = args.NameValuePairs.XFGetValue("UD1Member","None")
					Dim ud1MemberID As Integer = BRApi.Finance.Members.GetMemberId(si, dimTypeId.UD1, ud1Member)
					Dim ud1TextField As String = BRApi.Finance.UD.Text(si, dimTypeId.UD1, ud1MemberID, 1,Nothing,Nothing)
					
					Return ud1TextField
				End If

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

 

AlvaroSR
New Contributor II

Thank you, it is very useful and it is what I wanted. However, my client has more than one Text1 with the same value (repeated), then he need a sum of these cellamounts in one and displaying only the Text1 no repeated.

For that requirement, you would need to set up an attribute dimension that refers to the text field. 

AlvaroSR
New Contributor II

Hi TheJonG, I am trying this XFBR BR, but I don't get results:

 

If args.FunctionName.XFEqualsIgnoreCase("GetTextFieldForDescription2") Then
Dim ud1Members As List(Of String) = args.NameValuePairs.XFGetValue("UD1Members", "").Split(",").ToList()
Dim groupedValues As New Dictionary(Of String, Double)

For Each ud1Member In ud1Members
Dim ud1MemberID As Integer = BRApi.Finance.Members.GetMemberId(si, dimTypeId.UD1, ud1Member)
Dim ud1TextField As String = BRApi.Finance.UD.Text(si, dimTypeId.UD1, ud1MemberID, 1, Nothing, Nothing)
Dim value As Double

If Double.TryParse(ud1TextField, value) Then
If groupedValues.ContainsKey(ud1TextField) Then
groupedValues(ud1TextField) += value
Else
groupedValues.Add(ud1TextField, value)
End If
End If
Next

' Actualizar los valores en la base de datos
For Each kvp In groupedValues
BRApi.Finance.UD.Text(si, dimTypeId.UD1, BRApi.Finance.Members.GetMemberId(si, dimTypeId.UD1, kvp.Key), 1, kvp.Value.ToString(), Nothing)
Next

Return groupedValues
End If

 

Do you know what could be happening?

Thanks a lot.

What exactly are you trying to do and where are you call the rule? I can see right away that the return statement is returning the groupedValues variable which is a Dictionary. Only Strings can be returned in XFBR rules.