GQL Opening or Selecting Tickets on Another Terminal

Hi - I have a quick question maybe one of the Gurus here can help out with – from one terminal I want to select / display a ticket on another terminal. So when an action occurs on Terminal 2 I want it to create and display a new ticket on Terminal one.

I’ve successfully managed to create a ticket with the GQL API (createTerminalTicket) from Terminal 2 but when I do this it does not even appear in the ticket lister widget on Terminal 1.

Any ideas?

Maybe if you explain you aim it might be more obvious what you eng goal is.

Sure sorry. I have a custom page running in a browser (non Windows) which acts as a realtime display for customers. It pulls their data like balance, etc from the main SambaPOS server (mine) via GQL.

I want to add a button to “Start New Order” which will from Terminal 2 (Tablet, HTML/JS) create a new ticket (and select the customer entity) and display that ticket on Terminal 1 (cashier) so the order can begin.

If remote gql terminal 2 successfully create ticket, it should appears as normal on desktop Samba POS (terminal 1). Did you see ticket on ticket explorer but not ticket Lister?

So what you need to do is create a terminal ticket not add ticket there are two different GQL for that. You first create a terminal then a terminal ticket and then you can view it on other terminal. Add ticket will show up in ticket lister but not terminal

Right, so what I am doing now in Terminal 2 is this GQL command: gql.EXEC(gql.createTerminalTicket(terminalId);

I am then using: POS_updateTicketEntity(POS_Terminal.id, eType, eName);

My intended result is that when a button is pressed on Terminal 2 it creates a new ticket and sets the frequent customer (Customers entity by name). Viewing the output of console it appears these commands both fire without error however if I flip back to terminal 1 I do not show the ticket as being present.

I cannot fire the GQL command on Terminal 2 with the ID of terminal one because I do not have a way to get this ID – I tried using the terminal name but this does not work.

My end goal is simply when a button is pressed on Terminal 2 it creates a new ticket, sets the entity by name and then displays that ticket on Terminal 1.

Am I missing a vital step?

I use Terminal method and I can see orders on my main terminal. I didn’t use ticket lister tho. I use Entity Grid.

You need to know this about GraphQL Terminals and the related “Terminal” queries and mutations (ie. “Terminal Tickets”):

registerTerminal() is a reference to a Terminal (via terminalId) that is “locked” to the User who registered the Terminal (the Terminal Name is arbitrary), and that User can see only Terminal Tickets (via getTerminalTickets()) which are “owned” by that GQL Terminal User, even if the User is an Admin.

So if a User named “John” on a SambaPOS Terminal creates a Ticket, then the User named “Mary” on a GQL Terminal will not be able to see that Ticket (via getTerminalTickets).

By the same token, if a User named “Frank” on a GQL Terminal creates a Ticket, then the User named “Mary” on a GQL Terminal will not be able to see that Ticket (via getTerminalTickets). And “Frank” will not be able to see the Tickets owned by John, nor Mary.

However, the GQL query getTickets() will return ALL Tickets belonging to ANY user. And because of that, User “Mary” on a GQL Terminal, for example, will be able to “see” those Tickets (if presented in a list), and “Mary” can consequently open that Ticket via the Ticket Id.

The Ticket Lister in SambaPOS will generally show ALL Tickets, but it may depend on the Role Permission “Can View Other User Tickets”.

The lesson here is that a with a GQL Terminal, the functions related to “Terminal” (ie. any query or mutation containing the word “Terminal”) are not really related to a Terminal per-say, but rather the USER that invokes the Terminal functions. The word “Terminal” in GQL in this regard is a bit of a misnomer, and should probably have contained the word “User” instead, for example:

registerTerminal()       // should be registerUser()
unregisterTerminal()     // should be unregisterUser()
getTerminalTickets()     // should be getUserTickets()
getTerminalTicket()      // should be getUserTicket()
createTerminalTicket()   // should be createUserTicket()
loadTerminalTicket()     // should be loadUserTicket()
...
etc... // any query or mutation containing the word "Terminal" could/should be replaced by the word "User"

QMcKay thank you! This does make sense. So I guess my next questions is how does this play in when Terminal 1 is sambapos native and Terminal 2 is GQL.

I want to create a ticket and select it’s entity via Terminal 2 GQL and trigger that ticket to open on terminal 1 native samba and be displayed. I know how to pass data between the two thanks to your brilliant hub structure.

For some reason when I create the ticket via GQL it seems terminal one in native sambapos does not see it. Maybe I need to pass the ticket ID from GQL to SambaPOS and fire a rule to load said ticket. I am going to give that a try!

Yes, use the Id. It is “universal”.

Users can only “see” their own Tickets unless you use a Ticket Lister or getTickets().

Terminal Tickets are registered/owned by the User. This is true in SambaPOS native as well, as I explained.

I have staff that use SambaPOS all the time. From GQL, if i am not logged in as “them” I cannot see their tickets in POS module. However, if I use the Ticket Explorer in GQL, I see all Tickets, no matter what.

But terminal 1 should be able to see ticket isn’t it. I do see ticket create by gql on native Samba terminal.

I would think so. But I am unclear on what @Luis_Varsan means when he says “can’t see it”.

See it from where?

TicketList?
TicketLister?
TicketExplorer?
Script?
Other Automation?

Ah, Ticket Lister doesn’t see it. Entity Grid/Ticket Explorer does.