Deleting saved free tags

Good day.

Is there a way to delete or clear the saved free tags at the end of the day that were created that day so that new/different ones can be created the next day.

Thanks in advance,

I’m assuming this can not be done and am going to seek other solutions. Thanks.

Yes it is not possible atm but I can remember something similar was in my todo list.

If it is urgent we can try to find a solution by deleting free tags with SQL script.

That is OK. This was actually part of a solution to my other question about lunch specials. I thought that if the manager created a free tag first thing in the morning. In the name field he puts “#1” and “#2” for the 2 specials with their respective prices. The wait staff then only has to click the saved buttons for which special the customer ordered. Next morning he would clear the 2 buttons and enter the new ones for that day.

I have made a tutorial that I printed out to show them how to go into the product list and physically change the portion price. It will do in the interim. No rush.


Change the following SELECT query to a DELETE query (replace SELECT * with DELETE), and modify the WHERE constraint on the last line to use the Order Tag Group Name that you have (mine is called ‘Special Modifier’).

-- DeleteFreeTags.sql

USE [SambaPOS4]

SELECT * -- change this line to DELETE when you know you have the correct Group
FROM [dbo].[OrderTags]
where [OrderTagGroupId] = (select [Id] from [dbo].[OrderTagGroups] WHERE [Name]='Special Modifier')  -- change 'Special Modifier' to your Tag Group Name

Save the query as a .SQL file (i.e. DeleteFreeTags.sql).
Create an Action of type Start Process which launches a .BAT file containing a command similar to the following.

:: DeleteFreeTags.bat
sqlcmd -S localhost\sqlexpress -E -d SambaPOS4 -I -i DeleteFreeTags.sql

Create a Rule for event Work Period Ended, and fire the Action you defined above.

Thanks @QMcKay…I followed Your instructions to a “T”. I made the sql file and the bat file. Now I am not sure where to put them. I put a copy of each in the root directory and a copy in users\reg\mydocuments\sambapos4 folder, where the sambapos4.sdk file is. I looked at that with compactview and under ordertags there is no entries even though I have created the modifier, tested it, it saved a couple buttons. I also made up a couple more order tags and they are not in there either. not sure if I am looking in the right place. I made the action and rule and when I end the work period I get an error message to look in the log file. This is the first paragraph:

[Exception Info 1]

Top-level Exception
Type: System.ComponentModel.Win32Exception
Message: The system cannot find the file specified
Source: System
Stack Trace: at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Samba.Presentation.Common.ActionProcessors.StartProcess.Process(ActionData actionData)

That gives me the indication that the rule and action are doing their thing but I just don’t have the files in the right places.

It has been many years since I have played with batch files so not sure if I have it right.

Thanks again.

Ok, this is common, and you are correct - the file can’t be found, since by default Windows CMD executes from the Users path. Easy to fix.

Put the .BAT file and the .SQL file in the same folder (the location isn’t that important, so long as the path is readable - a public location that can be read by Everyone Group is good). Then in the .BAT file, add commands to switch the path to that folder. For example, my .BAT and .SQL file are in the path D:\Programs\POS\SALES, so my .BAT file looks like this:

:: DeleteFreeTags.bat
CD D:\Programs\POS\SALES

sqlcmd -S localhost\sqlexpress -E -d SambaPOS4 -I -i DeleteFreeTags.sql

OK…Got it partially working. I created a folder C:\pos then put the bat and sql files in it. In the action where it asks for a file name I put “C:\pos\deletefreetags.bat”. Now when I end the work period a cmd prompt window opens with the contents of the batch file wording. After about 5 seconds a bunch of text flashes and the window closes so fast I can not read it or get a screen shot. I go back to the tickets and the tags are still there. I did add an address to the batch file but it came up with some errors. Removed the address and the errors disappeared. That is where I thought about putting the full address for the file in the action.

I think I see the problem. In the sql file example you gave this line:

“where [OrderTagGroupId] = (select [Id] from [dbo].[OrderTagGroups] WHERE”

I do not know how to extract the [Id] from [dbo].[OrderTagGroups] in the database file. I think it might have stalled the process because I have not entered that ID. I have removed your ‘Special Modifier’ and inserted ‘Lunch Specials’, which is what I used for the Tag Group Name.

I am using MS SQL server 2012 as they may put more terminals in down the road and read that it would make things easier.

Thanks again…this is much appreciated.

This is more elaborate looking, and it is actually the process I use to run SQL commands. It logs output to a text file so you can see what is happening, and pauses execution of the BAT file at the end so you can see any other errors. When it all works properly, remove the pause command.

@echo off

:: deletefreetags.bat

:: set the Server, DB, SQL file, and ErrorFile

set SName=localhost\sqlexpress
set DbName=SambaPOS4
set SQL=deletefreetags.sql
set ERRFILE=ErrFile.txt

:: change to drive and path where BAT and SQL files are located

CD D:\Programs\POS\SALES

:: run the SQL file and log results to ERRFILE

@echo on
sqlcmd -S %SName% -E -d %DbName% -I -i %SQL% >> %ERRFILE% 2>&1

:: open ERRFILE in Notepad to show results of query operation
@notepad %ERRFILE%

:: pause the BAT file so we can see screen output

This portion of the query is where it extracts the ID for the Order Tag Group:

(select [Id] from [dbo].[OrderTagGroups] WHERE [Name]='Special Modifier')

It is a sub-query, within the larger query:

FROM [dbo].[OrderTags]
where [OrderTagGroupId] = (select [Id] from [dbo].[OrderTagGroups] WHERE [Name]='Special Modifier')

Your Start Process Action should include the path where the BAT file is located:

When you have it working properly, you can remove the pause statement from the BAT file, and switch Is Hidden to True in the Action.

@QMcKay Thanks for all the help with this. This is my first time working with SQL, I’m more hardware/basic windows troubleshooting type of guy and am learning alot.

I have the bat file working and I am assuming that it is running the sql file as I am getting the following in the ‘errfile’:

Msg 102, Level 15, State 1, Server DESK\SAMBAPOS4, Line 7
Incorrect syntax near ‘Specials’.

Just so you know how my menu is setup…I have a menu category called ‘Specials’. A product called ‘Lunch Specials’ with the default portion (normal, 1, 0.00). The order tag is called ‘Lunch Specials’ with free tag and save free tags checked and mapped to ‘Specials’ & ‘Lunch Specials’. I have created a tag called #1 with a price of 7.95 and another called #2 with a price of 10.50 and they have both now showed up in the order tag list.

I can open up the SQL Server Management Studio and connect to Sambapos4. I look around and can find the tables for [dbo].[OrderTags] etc but can not see anything that relates to the products/menu etc that is programmed into sambapos4.

Thanks for the ‘sub-query, within the larger query’ clarification.

Post the content of your SQL file so we can see the problem with the query.

@QMcKay …I found my mistake…my sql file is exactly the same as yours only when I took out ‘Special Modifier’ and inserted my Tag Group Name ‘Lunch Specials’ I forgot to add the quotation marks. Simple, but stupid mistake…I made myself do 10 laps of my town with a full rucksack.

Works great! I did the same for the supper specials. Ending the work period deletes both sets of tags.

Thanks again! Your help was much appreciated. This is great software and considering that I didn’t even know it existed 4 weeks ago and have never worked in a restaurant, this was the only thing that had me stumped.