Is it possible to convert semi-colon separated values into a list using AMP Script like the example below:
Structure in the data extension tab: 1 Orange ;2 Apples ;3 Peaches ;5 Plums
Expected Output:
- 1 Orange
- 2 Apples
- 3 Peaches
- 5 Plums
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityIs it possible to convert semi-colon separated values into a list using AMP Script like the example below:
Structure in the data extension tab: 1 Orange ;2 Apples ;3 Peaches ;5 Plums
Expected Output:
You can do it using the BuildRowsetFromString function:
%%[
set @list = "1 Orange;2 Apples;3 Peaches;5 Plums"
set @rows = BuildRowsetFromString(@list,";")
set @rowCount = rowCount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
set @row = row(@rows, @i) /* get row based on counter */
set @fruit = field(@row,1)
]%%
<br>Row %%=v(@i)=%%, fruit: %%=v(@fruit)=%%
%%[
next @i ]%%
%%[ else ]%%
No rows found
%%[ endif ]%%