Forum Discussion

PhilB's avatar
PhilB
New Contributor III
3 years ago

New Syntax for LookupRowFieldValue()

Summary

Is there any documentation and/or sample code showing how to use the new "dbWheres" argument in a LookupRowFieldValue() function?

Detail

In version 6.8 (maybe earlier), if you use .LookupRowFieldValue() with your criteriaExpression (i.e. - your where clause) as a string you get a warning that this syntax is obsolete. It still runs, but obviously we shouldn't use it going forward.

So, something like this now throws an warning:

.LookupRowFieldValue(si, dbLocation, tableName, criteriaExpression, fieldToReturn, defaultValue)
.LookupRowFieldValue(si, dbLocation.Framework, "SecUser", Name = 'Phil Brosnan', "Email", String.Empty)

OneStream wants you to use a new Syntax that replaces the criteriaExpression with a list of where clauses in a dbWheres object.

.LookupRowFieldValue(si, dbLocation, tableName, dbWheres, fieldToReturn, defaultValue)

Unfortunately, there is no documentation or examples on what a dbWhere object is, how to create one, or how to pass that dbWhere object into your dbWheres list.

My question is, does anyone know how to use this new “dbWhere” syntax in a LookupRowFieldValue function, or know how to do something similar with a different function? Just looking for some sample code I can leverage.

Thanks,

    • PhilB's avatar
      PhilB
      New Contributor III

      Hi Sai,

      Thanks for the response. I did look at Joe's post, but I think I missed the screen-shot with the example code. I'll try that and see how it works. Thanks again.

      • Here is something you can try.

         

        Dim objDBWheres As New List(Of DbWhere)
        Dim objDBWhere As New DbWhere("RegisterID",DbOperator.IsEqualTo,"E000204")
        objDBWheres.Add(objDBWhere)
        Dim objScnWhere As New DbWhere("WFScenarioName",DbOperator.IsEqualTo,"BudgetV1")
        objDBWheres.Add(objScnWhere)
        						
        Dim strFirstName As String = BRApi.Database.LookupRowFieldValue(si, "App", "XFW_PLP_Register", objDBWheres, "FirstName","")

         

         

        So this will create a WHERE similar to RegisterID='E000204' AND WFScenarioName='BudgetV1' (code does RegisterID=@RegisterID AND WFScenarioName=@WFScenarioName)

        You can use AppendWithORVersusAND to change the default of AND to an OR. I don't think anyone will be using an alternate parameter name. So you can create the object then use a set for ORVersusAnd rather than mentioning the parenthesis and alternate name.