Expand my Community achievements bar.

Join Cristinel Anastasoaie, Timothy Furlow, and Brent Kostak, WEDNESDAY, 2/28/24 @8am PT for the next Adobe Target Community Q&A Coffee Break on topics from the recent High Performance Recommendations Webinar PT 2 of the ongoing Target Personalization Maturity Webinar Series
SOLVED

Recommendations Designs - velocity - map

Avatar

Level 3

Hi,

I am trying to setup a Map array for design, I am able to set the map array but I can access it's value

Apache Velocity Engine - User Guide

#set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"})

$monkey.Map.get("banana") Doesn't work

Is map included?

rgds,

jerome

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

It seems that using the Map is where things go wrong.

$translateReadmore.en

$translateReadmore.fr

$translateReadmore.de

Those should work based on the example. Tried your use case as well:

#set( $translateReadmore = {"en" : "Read more", "fr" : "lire la suite", "de" : "Mehr darüber"})

#set( $language = "en" )

{

    "entityId" : "$entity.id",

    "test" : "$translateReadmore[$language]"

}

test comes through fine as Read more

View solution in original post

4 Replies

Avatar

Community Advisor

So it is not exactly what you are asking ... however this works for me.

#set( $monkey = {"banana" : "good", "roast beef" : "bad"})

{

    "entityId" : "$entity.id",

    "test" : "$monkey.banana"

}

Response

{

    "thirdPartyId": "ldksjflaksdjfldjlkf",

    "edgeHost": "mboxedge19283048309849803487.tt.omtrdc.net",

    "content": "{\n    \"entityId\" : \"top-secret-product\",\n    \"test\" : \"good\"\n}",

    "sessionId": "abc123554"

}

Seems like it does not need to be specified as a map.

Avatar

Level 3

Hi Eric,

Sorry I don't understand your answer.

Let me give you an example of what I want to do - If I want to translate a Design

#set( $translateReadmore.Map = {"en" : "Read more", "fr" : "lire la suite", "de" : "Mehr darüber"})

So I could use in the Design ($language determined based on Metadata)

$translateReadmore.Map.get($language)

Rgds,

Jerome

Avatar

Correct answer by
Community Advisor

It seems that using the Map is where things go wrong.

$translateReadmore.en

$translateReadmore.fr

$translateReadmore.de

Those should work based on the example. Tried your use case as well:

#set( $translateReadmore = {"en" : "Read more", "fr" : "lire la suite", "de" : "Mehr darüber"})

#set( $language = "en" )

{

    "entityId" : "$entity.id",

    "test" : "$translateReadmore[$language]"

}

test comes through fine as Read more

Avatar

Level 3

Yes it works, many thanks Eric !!