JavaScript syntax error | Community
Skip to main content
romana_lungbarrow
May 25, 2023
Solved

JavaScript syntax error

  • May 25, 2023
  • 3 replies
  • 1231 views

Hi,

I'm trying to write some JavaScript for a block in my email that pulls in fields from a data table (where possible). I am struggling with a syntax error somewhere and its really hard for me to debug as it is crashing Adobe Campaign quite severely. Can anyone see what's going wrong?

 

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by isahore

Hi @romana_lungbarrow,

This below highlighted is the extra bit here:

else { %>Departing <% }%><%= formatDate(targetData.tr_date, "%2D/%2M/%4Y") %> <% } %><% }%>

 

Thanks,

Ishan

3 replies

isahore
Community Advisor
isahoreCommunity AdvisorAccepted solution
Community Advisor
May 25, 2023

Hi @romana_lungbarrow,

This below highlighted is the extra bit here:

else { %>Departing <% }%><%= formatDate(targetData.tr_date, "%2D/%2M/%4Y") %> <% } %><% }%>

 

Thanks,

Ishan

david--garcia
Level 10
May 26, 2023

Give the following a go.

 

<% if (targetData.tr_nights == "any duration") { %>any duration <% } else if (targetData.tr_nights > 0) { %><%= targetData.tr_nights %> nights <% } else {//nothing} %> <% if (targetData.tr_ship) { %>aboard the <%= targetData.tr_ship %> <% } else { %>cruising<% }%> <% if (targetData.tr_passengers) { %>for <%= targetData.tr_passengers %> passengers<% }%>. <% if (targetData.tr_date == "any dates") { %>Departing any dates <% } else { %>Departing <%= formatDate(targetData.tr_date, "%2D/%2M/%4Y")%><%}%> <% if (targetData.tr_price > 0) { %> from £<%= numberWithCommas(parseFloat(targetData.tr_price).toFixed(2)) %>. <span style="mso-line-height: exactly; line-height:10px;"><br /><br /></span> <% }%> <% if (targetData.tr_reference) { %> Reference: <font style="font-weight: bold;"><%= targetData.tr_reference %></font><br> <% } %> <% if (targetData.tr_code) { %> Holiday code: <font style="font-weight: bold;"><%= targetData.tr_code %></font> <% } %>
Sukrity_Wadhwa
Community Manager
Community Manager
June 7, 2023

Hi @romana_lungbarrow,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!

Sukrity Wadhwa