I am experimenting with having a "Preferred Channel" picklist field on a Custom Preference Center Page hosted on CloudPages and would like to restrict field values to a specific subset of picklist values that are located as different rows in a designated Data Extension. I'd like to have this data attribute be limited to a single value, selected by the end user, within an expected range of values, so that it can be used as in Attribute Decision Split within Journey Builder.
Data Extension Details:
Data Attribute: Preferred Channel, Text(50)
Data Attribute: MatchId, Number, Default '1'
Data Extension Rows (3):
'Preferred Channel', 'MatchId' (Headers)
'Email', '1'
'SMS', '1',
'Phone Call', '1'
Here is the code that I'm currently working on, but I'm not able to return the values
%%[
var @matchId, @picklistValues, @preferredChannel, @numRowsToReturn, @rowCount, @i /*Declare variables*/
set @matchId = '1' /*Matching Key to return correct rows from designated Data Extension*/
set @numRowsToReturn /* Default: returns up to the first 2000 rows*/
set @picklistValues = LookupOrderedRows('Preferred Channel Picklist', @numRowsToReturn, 'Preferred Channel asc', 'MatchId', @matchId)
/*Grabs all rows (up to 2000) from the 'Preferred Channel Picklist' Data Extension, sorted by the Preferred Channel Data Attribute where rows have a
matching matchId of '1', which is the default value for all rows designated in this Data Extension*/
set @rowCount = rowcount(@picklistValues) /*Determine row count based on number of rows that exist in the data extension, up to 2000*/
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @preferredChannel
set @row = row(@picklistvalues, @i) /* get row based on counter */
set @preferredChannel = field(@row,"Preferred Channel")
if @i == 1 then
outputline(concat("<ul>"))
endif
]%%
<li style="border-bottom: 1px solid #ebeced;">
%%=v(@prefferedChannel)=%%
</li>
%%[
if @i == @rowcount then
outputline(concat("</ul>"))
endif
next @i
]%%
%%[ else ]%%
No rows found
%%[end if]%%
]%%
Note: I believe I'll need to do some additional work for those values to return as a dropdown in the picklist, but I wanted to confirm my approach, or if there is potentially an easier way to achieve managing attribute splits for "Preferred Channel' in Journeys based on a single attribute.