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 CubeView with one account as the member filter: A#A87999.  Formatting should be applied if the account is a Liability type.

I have a mostly working XFBR helper that can correctly apply formatting but only if I hardcode in the account reference.  Obviously that won't work for all but the simplest CV as reports are often dynamic with Member Expansions.

The mainly working formatting syntax as currently written:

If (XFBR(XFBR_FormattingHelper, AccountTypeIsLiability, Account=[A8799])=True) Then
TextColor = Red
End If

How do I make the parameter dynamic?  I've tried the following:

... Account=RowE1MemberName

... Account=|RowE1MemberName|

... Account=[RowE1MemberName]

... Account=[|RowE1MemberName|]

None seem to work.  Is there a different way to reference the standard available conditionals?

Thanks,
Dave

  • 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

  • EricOsmanski's avatar
    EricOsmanski
    Valued Contributor

    Account=[|MFAccount|]

    You can search for "Member Filter Substitution Variables" in the reference guide for more information.

    • db_pdx's avatar
      db_pdx
      Valued Contributor

      Hi Eric: thanks for the suggestion, that always doesn't appear to be working either.

      Formatting string:

      If (XFBR(XFBR_FormattingHelper, AccountTypeIsLiability, Account=[|MFAccount|]) = True) Then
      TextColor = Red
      End If

      XFBR:

      If args.FunctionName.XFEqualsIgnoreCase("AccountTypeIsLiability") Then
      Dim accountName As String = args.NameValuePairs.XFGetValue("Account")
      Dim accountId As Integer = BRapi.Finance.Members.GetMemberId(si,DimType.Account.Id,accountName)
      Dim strAccountType As String = BRapi.Finance.Account.GetAccountType(si,accountID).ToString
      If strAccountType = "Liability" Then
      Return True
      End If
      End If

       

      In general, it is unclear how the conditional logic is evaluated.  Is there documentation on this?  I'd go as far as to say its a bit buggy.  For example, the following do not work:

      If (RowE1MemberName = [|MFAccount|]) Then
      TextColor = Red
      End If

      If ('A87999' = [|MFAccount|]) Then
      TextColor = Red
      End If

      If (RowE1MemberName = RowE1MemberName) Then
      TextColor = Red
      End If

      • EricOsmanski's avatar
        EricOsmanski
        Valued Contributor

        Have you tried putting error logs in your BRString formula to see what is being passed in for the Account?

        The documentation is under section "Cube View Conditional Formatting" in the reference guide.