Forum Discussion

db_pdx's avatar
db_pdx
Valued Contributor
4 years ago

How to pass standard formatting conditionals to an XFBR rule?

Hello: Looking for guidance on how to implement an enhanced conditional formatting check.  It's quite simple, apply some formatting based on the account type. Consider the example of a single row...
  • db_pdx's avatar
    db_pdx
    4 years ago

    Thanks Eric, using the In syntax is a working solution, albeit a brute force one.  I would love to understand more how you arrived at the conclusion that |MF| substitutions won't work here.  This is the type of info I am hoping to see in the documentation.  Else we're just throwing ideas against the wall until something sticks.

    Final conditional string:

    If (RowE1MemberName In XFBR(XFBR_FormattingHelper, InAccountTypeIsLiability, Account=[AccountHierarchy])) Then
    TextColor = Red
    End If

    Final XFBR:

    If args.FunctionName.XFEqualsIgnoreCase("InAccountTypeIsLiability") Then
    Dim accountName As String = args.NameValuePairs.XFGetValue("Account")
    Dim accountId As Integer = BRapi.Finance.Members.GetMemberId(si,DimType.Account.Id,accountName)
    Dim accountDescendantsAreLiability As List(Of Member) = BRapi.Finance.Members.GetDescendants(si,BRapi.Finance.Dim.GetDimPk(si,"AllAccounts"),accountId).Where(Function(x) BRApi.Finance.Account.GetAccountType(si, x.MemberId).ToString = "Liability").ToList()
    Dim strLiabilityAccounts As String = String.Join(",",accountDescendantsAreLiability.Select(Function(x) x.Name))
    Return strLiabilityAccounts
    End If

    Couple of items if others stumble upon this thread:

    The conditional In statements expects a comma separated literal string. Not a List(Of String), and not a string delimited by anything else.

    This is still less than ideal as you are returning a large majority of the hierarchy for each and every member this is evaluated against and you must still update the XFBR string if you have multiple hierarchies in play.

    I'll file a bug/enhancement request for the issues and inconsistencies noted.

    Thanks,

    Dave