Skip to main content
edited body
Source Link
zuzannamj
  • 14.5k
  • 3
  • 27
  • 56

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, coso I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>fallback text for other values<br>
    %%[ endif

  next @i 
  endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, co I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>fallback text for other values<br>
    %%[ endif

  next @i 
  endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, so I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>fallback text for other values<br>
    %%[ endif

  next @i 
  endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

deleted 60 characters in body
Source Link
zuzannamj
  • 14.5k
  • 3
  • 27
  • 56

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, co I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>some<br>fallback text for noother value<br>values<br>
    %%[ endif

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, co I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>some text for no value<br>
    %%[ endif

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, co I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>fallback text for other values<br>
    %%[ endif

  next @i 
  endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.

Source Link
zuzannamj
  • 14.5k
  • 3
  • 27
  • 56

You can retrieve the array from the DE either using an AttributeValue function if the data sits in your sendable DE, or using a Lookup if it's in a related DE. You did not provide any details about your data structure, co I am assuming it's sitting in your sendabe DE like this:

enter image description here

Also I am assuming you want to display this inside an email, so I'd use AMPscript instead of SSJS to pull and parse the data using the BuildRowsetFromString function:

%%[
set @data = AttributeValue("data") /* get data from a sendable DE */

/* build a simple string from array */
set @string = replace(@data, "[", "") 
set @string = replace(@string, "]", "")
set @string = replace(@string, '"', '')

/* build a rowset */
set @rows = BuildRowsetFromString(@string,",")
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 @value = field(@row,1)

    /* conditionally display text based on array data */
    if @value == "value1" then ]%%
    <br>some text for value 1<br>
    %%[ elseif @value == "value2" then ]%%
    <br>some text for value 2<br>
    %%[ elseif @value == "value3" then ]%%
    <br>some text for value 3<br>
    %%[ else ]%%
    <br>some text for no value<br>
    %%[ endif

  next @i ]%%

%%[ else ]%%

No rows found

%%[ endif ]%%

I've added some conditions above (%%[ if @value == "value1" then ]%% <br>some text for value 1<br> etc.) to conditionally display text based on the values in the array, but without understanding what your use case is exactly it's hard to point to the best solution.