Help with conditonal printing of ticket tags/states (printer templates/entity screens)

For a ticket-listing entity screen I only want to show tags/states when they’re set.

For example:

[<br/>{TICKET TAG:Customer Name}]
[<br/>{TICKET TAG:Order #}]
[<br/>{TICKET STATE:Channel}]

Even though all are set, only “Order #” shows. When I test print each separately only “Order #” shows.

If I strip everything out and leave just the brackets, then everything prints just fine. e.g.:

{TICKET TAG:Customer Name}
{TICKET TAG:Order #}
{TICKET STATE:Channel}

What am I missing here? Or should I be using a ternary expression?

TIA

I made my ticket lister long time ago so I cant exactly remember what was the issue but I think it didnt format properly unless I had <J> or <L> before the line.

${TOTAL AMOUNT}<br/>
<L><size 12><block 10>
{ORDERS}
<L></block></size>

[ORDERS]
<J>  [=('{QUANTITY}x' + "    ").substring(0, 4)] {NAME}|${TOTAL AMOUNT}<br/>

If you can post some screenshots, might help me visualize what your issue is

2 Likes

You need to include the formatting too. <L00>

here’s an abridged version of template:


<J><block 1,0,0,0 #5ffffff center 200><color red>{TICKET NO}</color></block>
<J><block 1,0,0,0 #5ffffff left 215><color #2D89EF><br/>{TICKET TAG:Customer Name}<br/>{TICKET TAG:Order #}<br/>{TICKET STATE:Channel}</color></block>
<J><block 1,0,0,0 #5ffffff left 215><color #2D89EF>[<br/>{TICKET TAG:Customer Name}][<br/>{TICKET TAG:Order #}][<br/>{TICKET STATE:Channel}]</color></block>
<L><size 10><block>
{ORDERS}
<L></block></size>
<J><block 1,0,0,0 #5ffffff center 110><color #FFF79646>{TICKET QUANTITY SUM} </color></block>
<J><block 1,0,0,0 #5ffffff center 200><color #85bb65>{TICKET TOTAL} </color></block>

[ORDERS]
<J>  {QUANTITY}x {NAME}|{TOTAL AMOUNT}<br/>

Line one displays no problem. Line two shows only the order # ticket tag.
Left side is just with just {} and to the right is the expression [{}]
2021-11-28_22;06_1638158776_Samba.Presentation

I am thinking the expression might be escaping itself because of <br/> or doing some crazy stuff like attempting to divide.

works in one instance, but not another - it’s strange

<br/> taken out of expressions and same ol’ same ol’

I really don’t like loading up expressions to evaluate in the ticket lister because of the overhead so I’d really like to avoid a ternary expression.

<J><block 1,0,0,0 #5ffffff center 200><color red>{TICKET NO}</color></block>
<J><block 1,0,0,0 #5ffffff left 215><color #2D89EF>{TICKET TAG:Customer Name}<br/>{TICKET TAG:Order #}<br/>{TICKET STATE:Channel}</color></block>
<J><block 1,0,0,0 #5ffffff left 215><color #2D89EF>[{TICKET TAG:Customer Name}] <br/> [{TICKET TAG:Order #}] <br/> [{TICKET STATE:Channel}]</color></block>

2021-11-28_22;23_1638159780_Samba.Presentation

to further illustrate the issue:

2021-11-28_22;28_1638160084_Samba.Presentation

okay, now looking at that last screenshot it’s a type issue: numbers work, text doesn’t

Is there a different way to handle this type of expression with a string?

updated channel to an integer and bam, works

2021-11-28_22;31_1638160289_Samba.Presentation

But why is it important for you to have square brackets around your tags?

Sorry, I probably dont understand what would they do differently on ticket lister because its been a while since I worked on them

The brackets, as I understand them, and when used a certain way, will only print the data inside the brackets if it exists. It’s a way to add a line to a (ticket) template with the formatting inside and if the expression is null or empty nothing gets printed.

There are two different scenarios with two different types of data:

  • pickup by customer or delivery by restaurant which the lister displays customer name and phone number
  • delivery by third party in which case the ticket lister needs to show customer’s name, order number, and third-party service name (channel)

Data in each scenario does not exist in the other. So I’d like to mash everything into one line so there are no blank lines when displayed if some data isn’t present for that ticket.

After trolling the site, for strings if I use [='{TICKET STATE:Channel}'] then things print just fine. I figure I’ll enclose all that way just to be safe in case there’s an alphanumeric order number at some point.

1 Like
[='{TICKET TAG:Customer Name}'!=''?'<L00>{TICKET TAG:Customer Name}':'']
[='{TICKET TAG:Order #}'!=''?'<L00>{TICKET TAG:Order #}':'']
[='{TICKET STATE:Channel}'!=''?'<L00>{TICKET STATE:Channel}':'']

I already have something like that for one part

<J><block 1,0,0,0 #5ffffff left 215><color #2D89EF>[=('{ENTITY DATA:Customers:Name}' == '' ? '{ENTITY NAME:Customers}' : '{ENTITY DATA:Customers:Name}<br/>{ENTITY NAME:Customers}')]</color></block>

the issue is ternary expressions are more costly and with a lot of tickets there can be quite the lag on refresh

For the strings try surrounding it like this [<L00>1: [{TICKET TAG:Customer Name}]]

the double set of brackets work, too

thanks!

2 Likes

Thanks for clarifying that though! I now also know how to solve my “new row and empty line” issue when the entity isnt selected :sweat_smile:

2 Likes