AMPscript Vol.1 Help & solution

The Killer Challenge was:

As a Developer, I would like to…

build a cloud page that compiles and renders an accurate summary of tickets reservations with a breakdown by contact and by film. The page should also display a total of tickets booked.

The page myst show real time data and cannot relay on automations or SQL queries.

How we approached the challenge:

  • We returned the list of all reservations where tickets = 1, ordered by customer ID then film ID.
  • We retrieved the relevant attributes, add a few lookups to get the user friendly output (contact’s name instead of ID, film title and subtitle instead of ID).
  • We rendered all rows in an HTML table, added headers, rendered all rows using a loop.
  • We appended a new row to the same table, to return the total number of individual tickets booked (not the number of rows in the Data Extension…)
  • Finally, we implemented some logic that checks, for each row, If the next record contains the same contact ID and film ID. If so, we increment the number of tickets and keep on looping, otherwise we display the name of the client, name of the film and total number of tickets booked.
  • Oh, and we added a few checks on first and last row, as well, just to avoid annoying errors…

Still stuck?

Download our solution to this challenge by clicking the button below:

Leave a comment