Forum Discussion

ethanmgomes's avatar
ethanmgomes
New Contributor II
2 years ago

Hardcode value in column when loading CSV

Hello,

Im wondering if there is a way to hardcode a fieldtoken value when loading data from a csv. For example, I am using the below code:

Dim fieldTokens As New List(Of String)
fieldTokens.Add("xfText#:[Account]")
fieldTokens.Add("xfText#:[Entity]")
fieldTokens.Add("xfText#:[Amount]")
fieldTokens.Add("xfText#:[EmpID]") '<-- Want to hardcode this to '99999'

BRApi.Utilities.LoadCustomTableUsingDelimitedFile(si, .......)

But I want to hardcode the results of EmpID to value '99999' before I execute the 'LoadCustomTableUsingDelimitedFile' command. 

 

Any help on this would be much appreciated!

 

  • Hey db_pdx,

    Your response was helpful! I had to change the format to get the default value to load correctly. I was able to get it to work by using 1 semi-colon, and by removing the square brackets from defaultValue. See below for example:

    xfText#:[FieldHeader]:DefaultValue

     

    One important point to note, there must be a column header for the field that you are trying to hardcode. I had to name the column as "EmpID" in my csv for the defaultValue to catch. If I left it as a blank column (even if it's the last column in the csv), then the defaultValue would not populate.

     

    Thank you for your help,

    Ethan

  • db_pdx's avatar
    db_pdx
    Valued Contributor

    Hi ethanmgomes: I know there is a format for default values when loading from Excel files with NamedRanges, I wonder if it also works for the BR method?

    The format looks like: 

    xfText#:[FieldHeader]::[DefaultValue]

    Maybe give that a shot and see if it works.

    • ethanmgomes's avatar
      ethanmgomes
      New Contributor II

      Hey db_pdx,

      Your response was helpful! I had to change the format to get the default value to load correctly. I was able to get it to work by using 1 semi-colon, and by removing the square brackets from defaultValue. See below for example:

      xfText#:[FieldHeader]:DefaultValue

       

      One important point to note, there must be a column header for the field that you are trying to hardcode. I had to name the column as "EmpID" in my csv for the defaultValue to catch. If I left it as a blank column (even if it's the last column in the csv), then the defaultValue would not populate.

       

      Thank you for your help,

      Ethan

      • db_pdx's avatar
        db_pdx
        Valued Contributor

        Glad to hear you got it working.  And good to know regarding column headers.  One potential clarification for others if they read this thread.

        I went back through the Design and Reference Guide.  At least per the print materials the single-colon is a Static Value while the double-colon is a DefaultValue.  The main difference is: the static value will override every row for that column regardless if it is blank or not; while the default value is only used for blank rows.

        Cheers!   -db