Adding user defined elements into a Mobile Ticket template

hi All,

Has anyone been able to add a user defined element(e.g. Door Letter) into a Mobile Ticket template?

I have not been able to get the syntax right for this and just wondered if anyone else has been able to do it.

Cheers,

Glenn

Parents
  • Hi Glenn,

    This seemed to work for me if you're talking about a user defined ticket design element. You'll just need to update the '2' to whatever your user defined element number is.

    @Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.UserDefined.UserDefinedElement2)

    Fingers cross it works for you and is what you're after.

    Cheers,

    Thomas

Reply
  • Hi Glenn,

    This seemed to work for me if you're talking about a user defined ticket design element. You'll just need to update the '2' to whatever your user defined element number is.

    @Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.UserDefined.UserDefinedElement2)

    Fingers cross it works for you and is what you're after.

    Cheers,

    Thomas

Children
  • hi Thomas,

    Thanks very much for responding and sending through the code snippet.

    I have now tried placing the following into my HTML template but regardless of where I seem to place it, the mobile ticket fails to send.
    @Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.UserDefined.UserDefinedElement4);

    I believe the syntax is correct and that is definitely the correct name of the element I am trying to declare.

    Kind Regards,

    Glenn

  • Hi Glenn,

    Here's an example which seems to work for me. We're on v15.1.13

    I copied the sample Mobile Ticket template and then just chucked my code snippet anywhere.

    Are you testing within the Ticketing Setup>HTML Templates? Every time I run an order to test the template it prints all unprinted tickets and I have to go back and add new unprinted tickets. Unlikely your issue but just checking that's not the issue.

    Cheers,

    @using Tessitura.Service.Client.Templates
    @using System.Collections.Generic;
    @using System.Linq;
    
    @{
        var renderTicketElementsTable = false; // For debugging only!
    
        foreach (var ticket in Model.Elements.Tickets)
        {
            var ticketElements = ticket.TicketElements;
    
            var webPerformanceDescription = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Performance.WebPerformanceDescription);
            var performanceDate = Model.GetTicketElementValue(ticketElements, DesignElements.Ticket.Performance.PerformanceDate);
            var performanceBeginTime = Model.GetTicketElementValue(ticketElements, DesignElements.Ticket.Performance.PerformanceBeginTime);
            var theatre = @Model.GetTicketElementValue(ticketElements, DesignElements.Ticket.Seat.Theatre);
            var sectionDescription = Model.GetTicketElementValue(ticketElements, DesignElements.Ticket.Seat.SectionDescription);
            var seatRow = Model.GetTicketElementValue(ticketElements, DesignElements.Ticket.Seat.SeatRow);
            var seatNumber = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Seat.SeatNumber);
            var nScanNumber = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Seat.NScanNumber);
            var priceTypeAlias = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Seat.PriceTypeAlias);
            var priceZoneDescription = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Seat.PriceZoneDescription);
            var orderNumber = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Order.OrderNumber);
            var ticketNumber = Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.Seat.TicketNumber);
    
            <!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
            <div style="margin:0px auto;max-width:600px;">
                <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
                    <tbody>
                        <tr>
                            <td style="border-top:1px solid #DDD;direction:ltr;font-size:0px;padding:20px 0 0;text-align:center;">
                                <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td style="vertical-align:top;width:600px;" ><![endif]-->
                                <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                        <tbody>
                                            <tr>
                                                <td style="vertical-align:top;padding:0 10px;">
                                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                                        <tr>
                                                            <td align="left" style="font-size:0px;padding:0;padding-bottom:20px;word-break:break-word;">
                                                                @if (renderTicketElementsTable)
                                                                {
                                                                    <table style="color: #666; font-size: 13px; width: 100%; background-color: #f2f2f2; margin: 0px auto 30px;">
                                                                        <caption style="background-color: #e6e6e6; padding: 10px; text-align: left;">Available Ticket Design Elements</caption>
                                                                        <thead>
                                                                            <tr>
                                                                                <th style="text-align: left; padding: 3px 10px;">Name</th>
                                                                                <th style="text-align: left; padding: 3px 10px;">Value</th>
                                                                            </tr>
                                                                        </thead>
                                                                        @foreach (var el in ticket.TicketElements)
                                                                        {
                                                                            <tbody>
                                                                                <tr>
                                                                                    <td style="padding: 2px 10px;"><pre style="margin: 0;">@el.Description</pre></td>
                                                                                    <td style="padding: 2px 10px;"><pre style="margin: 0;">@el.Val</pre></td>
                                                                                </tr>
                                                                            </tbody>
                                                                        }
                                                                    </table>
                                                                }
                                                                <div style="font-size:13px;line-height:1;text-align:left;color:#000000;">
                                                                    <div style="font-size: 19.5px; font-weight: bold; margin: 0 0 5px;">@webPerformanceDescription</div>
                                                                    @if (theatre != "")
                                                                    {
                                                                        <div style="font-size: 15px; margin: 10px 0 20px;">@theatre</div>
                                                                    }
    
                                                                    @if (performanceDate != "" || performanceBeginTime != "")
                                                                    {
                                                                        <table role="presentation" style="border: 0; margin-top: 20px;">
                                                                            <tr>
                                                                                <td>
                                                                            Here's my custom data field: @Model.GetTicketElementValue(ticket.TicketElements, DesignElements.Ticket.UserDefined.UserDefinedElement3)
                                                                                </td>
                                                                            </tr>
    
                                                                            @if (performanceDate != "")
                                                                            {
                                                                                <tr style="vertical-align: top;">
                                                                                    <td style="white-space: nowrap;  margin: 0; padding: 0 0 5px; font-weight: bold;">Date</td>
                                                                                    <td style="padding: 0 0 5px 15px;">@performanceDate</td>
                                                                                </tr>
                                                                            }
                                                                            @if (performanceBeginTime != "")
                                                                            {
                                                                                <tr style="vertical-align: top;">
                                                                                    <td style="white-space: nowrap; margin: 0; padding: 0 0 5px 0; font-weight: bold;">Time</td>
                                                                                    <td style="padding: 0 0 5px 15px;">@performanceBeginTime</td>
                                                                                </tr>
                                                                            }
                                                                        </table>
                                                                    }
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <!--[if mso | IE]></td></tr></table><![endif]-->
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
            <div style="margin:0px auto;max-width:600px;">
                <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
                    <tbody>
                        <tr>
                            <td style="direction:ltr;font-size:0px;padding:0 0 20px;text-align:center;">
                                <!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td style="vertical-align:top;width:300px;" ><![endif]-->
                                <div class="mj-column-per-50 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                        <tbody>
                                            <tr>
                                                <td style="vertical-align:top;padding:0 10px;">
                                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                                        <tr>
                                                            <td align="left" style="font-size:0px;padding:0;word-break:break-word;">
                                                                <div style="font-size:13px;line-height:1;text-align:left;color:#000000;">
                                                                    <table role="presentation" style="border: 1px solid #CCC; width: 100%;" width="100%">
                                                                        <tr>
                                                                            <td style="padding: 30px 0;" align="center" class="qr-code-wrapper">
                                                                                @Raw(Model.GetQRCode(@nScanNumber, 8, "#000000"))
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                    <div style="margin: 0 0 -1px;"></div>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <!--[if mso | IE]></td><td style="vertical-align:top;width:300px;" ><![endif]-->
                                <div class="mj-column-per-50 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                        <tbody>
                                            <tr>
                                                <td style="vertical-align:top;padding:0 10px;">
                                                    <table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
                                                        <tr>
                                                            <td align="left" style="font-size:0px;padding:0;word-break:break-word;background-color: #CCC">
                                                                <div style="font-size:13px;line-height:1;text-align:left;color:#000000;">
                                                                    <div style="font-size: 14px; line-height: 15.6px; border: 1px solid #CCC;">
                                                                        @{
                                                                            var seatRowLabelPieces = new List<string>();
    
                                                                            if (seatRow != "")
                                                                            {
                                                                                seatRowLabelPieces.Add("Row " + seatRow);
                                                                            }
    
                                                                            if (seatNumber != "")
                                                                            {
                                                                                seatRowLabelPieces.Add("Seat " + seatNumber);
                                                                            }
    
                                                                            var labels = new List<string> {
                                                                                sectionDescription,
                                                                                priceZoneDescription,
                                                                                string.Join(", ", seatRowLabelPieces),
                                                                                priceTypeAlias
                                                                            }.FindAll(s => s != "");
                                                                        }
    
                                                                        @if (labels.Count() > 0)
                                                                        {
                                                                            <table role="presentation" style="width: 100%; background-color: #FFF; border-bottom: 1px solid #CCC;">
                                                                                <tr>
                                                                                    <td style="padding: 15px 0;">
                                                                                        <table role="presentation" style="width: 100%; font-weight: bold; background-color: #FFF; border: 0; text-align: center;">
                                                                                            @foreach (var label in labels)
                                                                                            {
                                                                                                <tr>
                                                                                                    <td style="padding: 4px 0;">@label</td>
                                                                                                </tr>
                                                                                            }
                                                                                        </table>
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        }
    
                                                                        @{
                                                                            var details = new Dictionary<string, string>() {
                                                                                { "Order Number", @orderNumber },
                                                                                { "Ticket Number", @ticketNumber },
                                                                            }.Where(d => d.Value != "").ToList();
                                                                        }
    
                                                                        @if (details.Count() > 0)
                                                                        {
                                                                            <table cellpadding="0" cellspacing="0" role="presentation" style="text-align: center; width: 100%; background-color: #FAFAFA; font-size: 11px; color: #666; line-height: 13px;">
                                                                                <tr>
                                                                                    @{
                                                                                        for (var i = 0; i < details.Count(); i++)
                                                                                        {
                                                                                            var style = i == 0 ?
                                                                                                "padding: 10px 5px 2px;" :
                                                                                                "padding: 10px 5px 2px; border-left: 1px solid #CCC;";
    
                                                                                            <th style="@style">@details[i].Key</th>
                                                                                        }
                                                                                    }
                                                                                </tr>
                                                                                <tr>
                                                                                    @{
                                                                                        for (var i = 0; i < details.Count(); i++)
                                                                                        {
                                                                                            var style = i == 0 ?
                                                                                                "padding: 2px 5px 10px; font-weight: normal;" :
                                                                                                "padding: 2px 5px 10px; font-weight: normal; border-left: 1px solid #CCC;";
    
                                                                                            <th style="@style">@details[i].Value</th>
                                                                                        }
                                                                                    }
                                                                                </tr>
                                                                            </table>
                                                                        }
                                                                    </div>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <!--[if mso | IE]></td></tr></table><![endif]-->
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!--[if mso | IE]></td></tr></table><![endif]-->
        }
    }

  • hi Thomas,

    Just letting you know I was able to add in the user defined element by using your code snippet as a guide so thanks very much for sending through this information.

    Cheers,

    Glenn

  • Great to hear. Glad I could help!