Velocity Token URL not populating correctly (repeats the same URL)

Chalo
Level 2

Velocity Token URL not populating correctly (repeats the same URL)

Hi,

I'm having this issue in which I want to retrieve the link URL from a webinar depending on their eventid (being the eventid a dedupe field.

My code is this one: 

 

#set($targetEventId = "93992165641")
#set($index = -1)

#foreach($webinar in $zoomWebinars_cList)
    #if($webinar.eventid == $targetEventId)
        #set($index = $foreach.count - 1)
        #break
    #end
#end

#if($index != -1)
    <a href="${zoomWebinars_cList.get($index).joinURL}">Access Webinar</a>
#else
    Webinar not found.
#end

 

Thing is I want to include 3 velocity token in 1 single email. The 3 tokens will appear as hyperlinks but will only redirect to 1 session.

 

I know there are some resources for #foreach thing but my coding skills are not good enought I believe.

 

Does anyone know what's causing the problem here?
I did some testing and index works fine as it retrieves the correct eventid and URL but won't populate it correctly in the hyperlink.

Chalo_1-1718970664429.png

 

 

 

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Token URL not populating correctly (repeats the same URL)

For clarification, are you saying you want to output the joinURL for the 3 objects that match each of 3 different eventid values? Please mock up the expected output, it's not clear yet.
Chalo
Level 2

Re: Velocity Token URL not populating correctly (repeats the same URL)

Hi @SanfordWhiteman ,

 

I have one object whose values are webinar sessions.
I want to output the matching joinURL to the eventID it belongs to.

Chalo_0-1719228309332.png

Example:

I want to be able to send 1 email that has in it 3 CTAs for the 3 webinars.

So in that email I'd like the link fo the CTA to be a Velocity Script token.
Since joinURLs are dynamic depending on the user, I have to exactly retreve the joinURL from the object.

Say I have  a table:

Webinar 1Date 1Access Webinar
Webinar 2Date 2Access Webinar
Webinar 3Date 3Access Webinar

 

The "Access Webinar" would be the Velocity Script token with the joinURL specific of the lead who's opening the email (and that has the Velocity code I put at the start of the thread).

 

So the issue is, I have 3 webinars with a unique event ID:
Webinar 1's eventID is 1111

Webinar 2's eventID is 2222

Webinar 3's eventID is 3333

 

I will change the eventID on each Velocity token in the targetEventId and in the end, it will only show 1 joinURL for only 1 event ID.

#set($targetEventId = "93992165641")

Chalo_1-1719229061355.png

End result is:

Webinar 1 has joinURL matching eventID 1111 (good)

Webinar 2 has joinURL matching eventID 1111 (wrong, they should've had joinURL matching eventID 2222)

Webinar 3 has joinURL matching eventID 1111 (wrong, they should've had joinURL matching eventID 3333)

 

Hope this helps to clarify the issue, let me know if I need to explain further.
Thanks!