Forum Discussion

fc's avatar
fc
Contributor
10 hours ago

Use 2 fields to determine dimension value in datasource

Hi all,

I need to set up a complex expression to assign a specific value to the U6 dimension based on 2 source fields. Below part of the list of those source fields.

The code I set up for the complex expression is the following:

Dim fields As List(Of String) = api.Parser.DelimitedParsedValues()

Brapi.ErrorLog.LogMessage(si, "Field count (List.Count): " & fields.Count)

If fields.Count > 4 Then
    Dim loadedAccount As String = fields(4)
    Brapi.ErrorLog.LogMessage(si, "loadedAccount: '" & loadedAccount & "'")
    
    If Left(loadedAccount, 2) = "00" Then
        Return Right(loadedAccount, 8)
    End If
Else
    Brapi.ErrorLog.LogMessage(si, "WARNING: only " & fields.Count & " fields; skipping Account logic")
End If

Every time I launch the loading process, however, it prints the WARNING message for all the rows, as if it didn't find any source field.
Am I doing something wrong / is there an alternative way to retrieve the fields values that I am not considering?

Thank you for the help!

2 Replies

  • BenEppel's avatar
    BenEppel
    New Contributor III

    Since this is a connector data source, I don't think api.Parser.DelimitedParsedValues() will work. I've used logic like this for complex expressions in connector sources. Below is index based, so field 1 will be 0, field 2 will be 1, ect..

     

    Dim fieldValues As String() = args.Line.Split(","c)
    
        Dim Field1 As String = fieldValues(0).Trim()
        Dim Field2 As String = fieldValues(1).Trim()
        Dim Field3 As String = fieldValues(2).Trim()
        Dim Field4 As String = fieldValues(3).Trim()

    I would recommend using a composite transformation rule if you can. There are examples in the design and reference guide.