I've got a bit of a quandary. I have a Looping Block that is supposed to parse through different column names to pull the appropriate Value from a DE. The problem is that the Variable that determines the column has the last character truncated when placed in the LookUp function, thus causing my look up to fail. When I call the Variable itself, it is not truncated. If I manually set the variable (e.g., SET @var = 'ThisValue'), it also doesn't truncate and works fine. It's only if the Variable is receiving it's Value from the Looping Block and then placed into the LookUp that it truncates the last character in the Value. Upon further testing, it seems like the issue specifically lies with whatever the last Value is.
@PrimaryKey has already been set @VarString = 'Column1Name|Column2Name|'
DataExtension Data Set:
PrimaryKey|Column1Name|Column2Name PrimaryKey|Text for 1 |Text for 2
%%[ SET @VarString = Substring(@VarString,1,Subtract(Length(@VarString),1)) SET @rows = BuildRowsetFromString(@VarString,'|') SET @rowCount = rowCount(@rows) IF @rowCount > 0 THEN FOR @i = 1 TO @rowCount DO SET @row = row(@rows,@i) SET @Column = field(@row,1) SET @Display = LookUp('ent.DataExtension',@Column,'PrimaryKey',@PrimaryKey) ]%% %%=v(@Display)=%%<br/> %%[ NEXT @i ENDIF ]%%
The error message I would receive in the above scenario would be:
●The Lookup function call failed because the specified lookup field does not exist for the data extension Data Extension: ent.DataExtension Invalid Field Name: Column2Nam Function Call: LookUp('ent.DataExtension',@Column,'PrimaryKey',@PrimaryKey) Message Context: Test ●Column 'Column2Nam' does not belong to table.
What I'm aiming for is this:
Text for 1 Text for 2
If I were to call on @Column by itself, it will display 'Column2Name' (assuming we already made it to the second value in the string). The error message only calls out the last Value, so I assume all the values before it worked fine, but I don't understand why it decides to truncate the last value.
Again, if I manually set the variable, it doesn't have an issue.
SET @Column = 'Column2Name' SET @Display = LookUp('ent.DataExtension',@Column,'PrimaryKey',@PrimaryKey)
Lastly, because I know you may ask, if there's only a SINGLE value in the string, it will truncate the single value.
The string is built from reused code that is throughout an email (basically, this all is to display some copy in the footer depending on what content was displayed in the email), and the code concatenates tags together using Pipes in between. In the code example above, there is a Substring call to remove the last pipe from the string, but it doesn't itself remove the last character from the last value.
I can probably figure out a solution by not removing the final pipe and stopping one Loop short (so it doesn't try looping through a black value), but I just want to know WHY it's truncating and any solutions to not get it to truncate.