Hi All,
I'm working on our HTML email ticket template.
I've made a copy of the Mobile Ticket template and have been able to make the changes that I need except for the date format.
The current format is YYYY-MM-DD which isn't the most user friendly, so I'm trying to change it to dd MMM yyyy (e.g. 31 Dec 2020).
I've managed to convert the performanceDate var to a DateTime as follows:
However, the only function available on the date2 is "ToShortDateString()".
My web research suggests there should be a ToString("dd MMM yyyy") that I can use, but this doesn't work and intelisense doesn't have ToString() for my date var.
Any ideas on how to format this date?
Many thanks,
Hi Dara,
I was able to use ToString with the following tweak to your date2 variable:
var date2 = DateTime.ParseExact(performanceDate, "yyyy-MM-dd", null); var performanceDate = date2.ToString("dd MMM yyyy");
Thanks Thomas.
I tried that but unfortunately, it throws an error when I click 'View Tickets' on the website.
The following is the error:
Rest Exception: BadRequest Description: An error occurred while rendering the template. Object reference not set to an instance of an object.
Response Body: [ { "Code": "", "Description": "An error occurred while rendering the template.\r\n\r\nObject reference not set to an instance of an object.", "Details": " at Tessitura.Service.Impl.Templates.TemplateRenderer.RenderTemplate[T](String template, T model, String cacheKey)\r\n at Tessitura.Service.Impl.Templates.TemplateService.RenderConstituentInfo(String constituentId, String templateBody, List`1 nameValues, String cacheKey)\r\n at
.....
If it works for you, but gives an error for me, I wonder if it's due to the difference in date formatting I have here in Ireland vs US date format.
I got it working .
Seemed to need a combination of both my first method and your suggestion Thomas.
The following is the code that worked for me, just in case anyone else on this side of the pond needs this for their mobile ticket:
I have another HTML Template editing question for the wise folk out there.
I want to display the orderId at the top of the Online Tkt Shell.
I'm using the following code, but it throws an error:
Any ideas?
Great work!
Could you use the order id from the OrderProductView model?
var myOrderId = Model.OrderProductView.Id
Unfortunately, that didn't work for me Thomas, but thank you for the help.
I think I'll have to open a support ticket on this one.
I **think** what might be happening here is that your var declaration (var myOrderId) is being assigned the integer type, and if you try to display an integer you must convert it to a string or you will get a type error.
What if you used in your code block:
string myOrderId = Model.OrderProductView.Id.ToString();
And then referenced it in your html code with: @myOrderId
Does that make it work?
Also, I am assuming here that your order actually HAS products.. If your order does not have products then the Model.OrderProductView will be NULL and you will get a NULL reference error..
Just wanted to chime in and say thanks for posting this solution, I've been struggling with the exact same issue the last few dates, so it was great to come on the forums and find exactly what I needed!
Thanks,Sarah Covie
PortTIX | Portland, Maine
I'm still struggling with making this update to my template and get an error whenever I try to "View Tickets" via the Upcoming Events page. I'm trying to make this date format change to a copy of the Mobile Tkt Shell - Online Account template. Can you tell me where you put this coding into the template or did you update a different HTML template?
Thank you,
Gina Harrower
And I just found the answer in the knowledge base! Thanks, Gina