Expand my Community achievements bar.

SOLVED

how to remove duplicate attribute value entities from the design

Avatar

Community Advisor

Hi Team,

 

I would like to skip the entity.Id if its attribute (entity.offerId) has already been shown in the recommendations. I am trying to use velocity logic but this is not running as expected:

 

The design :

#set($uniqueEntities=[])
#foreach($e in $entities)
#if($foreach.index <=12)
#if($uniqueEntities != ($e.offerId))
#set($uniqueEntities=$e.offerId)
#end
$uniqueEntities,
#set($foreach.index = $foreach.index + 1)
#end
#end

 

 

 

Response in request :

"content""OFF-56938,\nOFF-44046,\nOFF-27626,\nOFF-60503,\nOFF-49318,\nOFF-52824,\n1355738,\nOFF-13099,\nOFF-27626,\nOFF-11757,\n1355717,\nOFF-27305,\nOFF-42752,\n\n ",
 
 
I do not want OFF-27626 to reappear again.Each offerId has unique entity.id.
 
Any help on this would be really appreciated.
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I'm not a scripting expert, but it looks like you are evaluating if a string is equal to an array which seems incorrect.

#if($uniqueEntities != ($e.offerId))

Seems like you need to loop through the array and check if each item is equal.

Hope that helps,

Ryan

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

I'm not a scripting expert, but it looks like you are evaluating if a string is equal to an array which seems incorrect.

#if($uniqueEntities != ($e.offerId))

Seems like you need to loop through the array and check if each item is equal.

Hope that helps,

Ryan