Creates a rowset from a character string by splitting the string at the specified delimiter.
Availability
<table> <tr> <td>Marketing Cloud Engagement</td> <td>✅ Yes</td> </tr> <tr> <td>Marketing Cloud Next</td> <td>✅ Yes</td> </tr> </table>Syntax
BuildRowSetFromString(sourceData, delimiter)
The BuildRowSetFromString() function has two parameters:
sourceData(string): Required. A string that contains the data to load into a rowset.delimiter(string): Required. The character (such as a comma) that is used as a delimiter in the source data.
Usage
To call the function, pass it the string of data that you want to convert to a rowset, and the character that is used as a delimiter in the source data.
Basic Usage
This example creates a variable with a string of data, and another variable that contains the delimiter for that data. The example uses these variables to create a rowset from the string of data.
%%[
Set @dataString = "123|456|789"
Set @dataDelimiter = "|"
BuildRowsetFromString(@dataString, @dataDelimiter)
]%%
The example returns a rowset with three rows.
123
456
789
Processing Attribute Names
This example shows how to pass and process attribute names.
%%[
Var @queryparams
Var @row
Var @name
Var @value
Set @queryparams = BuildRowsetFromString(QueryParameter('names'),'|')
For @i = 1 to Rowcount(@queryparams) do
Set @row = Row(@queryparams, @i)
Set @name = Field(@row,1)
Set @value = QueryParameter(@name)
]%%
Passed <b>name:</b> %%=v(@name)=%% with <b>value:</b> %%=v(@value)=%%<br/>
%%[
next @i
]%%
When passed the following input:
names=career|firstname|lastname&career=marketer&firstname=Angela&lastname=Ruiz
The function returns:
Passed name: career with value: marketer
Passed name: firstname with value: Angela
Passed name: lastname with value: Ruiz
Because this function returns the rowset in one column, and this column doesn’t have an assigned name, you refer to the column within a function using an ordinal number:
Field(Row(BuildRowSetFromString('123|456', '|'), 1), 1)