Forum Discussion

HeatherB_eCap's avatar
HeatherB_eCap
Contributor III
3 years ago

Question about Complex Expressions built on Connector Data Sources

When building a Data Source bound to a Connector business rule, if a need arises to use a Complex Expression, and that expression requires referencing several unbound fields, what is the proper statement to use to retrieve those field values in the expression? 

I had been told to use the args.Line.Split function. For example, if I needed the Entity field in the data set, and Entity was the 10th field in the list, the expression would be: Dim entity As String = args.Line.Split(",")(9)

The "9" is used instead of "10" because the zero-base index.

I'm finding this args.Line.Split statement does not work properly if the field value contains a comma. The field imports correctly into the data set, but the args.Line.Split statement cannot differentiate a comma delimiter from one embedded in the field value and it ends up returning the wrong field. 

Is there another statement that can be used in Connector based Data Sources to reference fields in complex expressions?  

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    Technically the separator is ", " (comma and space), so maybe try that. Obviously this doesn't solve the problem if your value contains that same string. Generally speaking, when you drop on args.Line it becomes hack-territory, so chances that things will break somewhere are high.

    An alternative approach could be to map that extra field to a spare UD (if you have it), so you can reference it in a Conditional Rule from the transformation rule of the dimension you're writing the expression for; all the UD values could then transform to None with a wildcard mask.

  • Thank you JackLacava, you've confirmed my suspicions. In my case, it sounds like I need to either move the work done in the complex expressions to the Connector rule itself, or "cleanse" the data in the Connector rule to remove the commas to avoid the parsing corruption. Just as an fyi, I can't use UD's because the data being imported is for TXM so it's being imported into attributes.  Thanks so much!

    • MardayT's avatar
      MardayT
      New Contributor

      So how have you fixed this situation ? I have similar problem too

      • HeatherB_eCap's avatar
        HeatherB_eCap
        Contributor III

        Hi MardayT, in my connector business rules, I use Replace statements to remove commas from all fields that might contain it. Then, you can use the args.line.split command in complex expressions to reference field values. Note that connector data sources appear to  sometimes append empty spaces to the end of field field values, so I usually include .Trim statements as well to get rid of those. Hope that helps!