Issues with opening ticket with table/entities deleted

I just corrected what has caused a problem in my ticket showing two entities because of creating new entities type and two new entity screen (Ground Floor, First Floor).

Then I have to reprint a ticket that was settled 2 days ago. I enter ticket screen and when i clicked display, it caused an error and exit sambapos. There is this information tag on ticket screen, where the table info row is blank on this tickets and some other tickets. I found out this was due to where I deleted the entities and move the table that was suppose to be in “First Floor” to “Table” entities type. Only the ticket which has information on the table info row can be displayed with no problems. The tickets that is before my corrections cannot be opened and caused error. Anyway I can do around this? I try to remake the entities back to the old settings but it still does not update and crashed. Is there anyway I can insert the table number back into the tickets in SQL Studio?

You will have to correct it manually using SQL Studio yes. You cant delete entities if they are assigned to a ticket so did you delete them manually?

The methods I use was because the duplication of entities on any ticket if I moved table, so I move each entities from FirstFloor/GroundFloor back to Table, and then removed the FirstFloor and GroundFloor entities type. That’s how every ticket went blank on the table row infomations. And the only ticket without table information crash Samba if I clicked Display on Ticket screen. I did not use SQL to do it as I’m not an expert. So is there a way to put back in the table informations for each ticket? :frowning:

You will need to run an update statement in SSMS to fix the table called [TicketEntities].

Basically, you want to update the column [EntityTypeId] to match the Entity Type of the Entities that you moved/changed.

Here is a query that should show offending records:

SELECT distinct
 te.[EntityTypeId] as [BadId]
,e.[EntityTypeId] as [FixId]
,[EntityId]
,[EntityName]
FROM [TicketEntities] te
JOIN [Entities] e on e.[Id]=te.[EntityId]
WHERE 1=1
 and te.[EntityTypeId] != e.[EntityTypeId]
ORDER BY [EntityName]

That should produce a list of records where the Entity Type Id in the Ticket does not match the Entity Type Id of the Entity itself. Post the results here, and I can give you a simple update statement to use in order to fix it.

1 Like

hi,

here is the results

3,2,116,A01
3,2,117,A02
3,2,118,A03
3,2,119,A04
3,2,120,A05
3,2,121,A06
3,2,122,A07
3,2,123,A08
3,2,124,A09
3,2,125,A10
3,2,126,A11
3,2,127,A12
4,2,137,C01
4,2,138,C02
4,2,139,C03
4,2,140,C04
3,2,130,G01
3,2,131,G02
3,2,132,LT01
3,2,128,S01
3,2,133,T01
3,2,134,T02
3,2,135,T03
3,2,136,T04

Those are the entities that I moved from originally FirstFloor/GroundFloor back to Table and then I deleted the Entity FirstFloor/GroundFloor type.

After you run this UPDATE statement, you can run the SELECT statement above to confirm it is fixed. If it is fixed, the SELECT statement should return no results.

UPDATE te
SET te.[EntityTypeId] = e.[EntityTypeId]
FROM [TicketEntities] te
JOIN [Entities] e on e.[Id]=te.[EntityId]
WHERE te.[EntityTypeId] != e.[EntityTypeId]

Thank you sir! OMG you’re a godsend! It’s all fixed now. Cheers!!! :slightly_smiling: