Sql query INSERT INTO - how work?

I started to understand in sql, to extend the functionality.
but my simple script for some reason does not work

sql.ExecSql(“INSERT INTO [Users] ([PinCode], [Name], [UserRole_Id]) VALUES (7777775, t5tu, 4)”)

what am I doing wrong?

does it return any error at all?

What does it do?


Why are you trying to manually modify the database? What exactly are you trying to do that you feel SambaPOS cant so you must manually edit database?

If you can answer that we can probably help you come up with a better solution.

It looks like hes trying to manually change Pin Code for users…

That is not how you use the Execute Script action and that is not a propper SQL Script.

Do you know what your doing with SQL or is this a first attempt? I strongly advise you not to try and edit database manually unless you know exactly what you are doing. You will mess it up beyond repair.

We can help you understand how to use the action and SQL but can you please explain more of why your wanting to do that it will help us help you.

Here is a really good resource to learn how to use Execute Script action and how to write a propper SQL script. TimeTrex Punch is an Execute Script action and then I show the script.


I realized now that the string does not contain any semicolons… that should throw an error at least…


It looks like he is trying to automate creating a user…I cant make any sense of it though. Are you just testing it? It would make no sense why you use an automation command to make one single user.

thanks for answers.
he does not return any errors, like a script is performed.

@Jesse, Yes, I know what to do with the base.
I wanted to add a new user.

I understand that adding a user will not damage anything, because the table does not depending on others.

  • I have long worked Sambapos s not much studied the structure of the database in sql

in this particular case, I want to automate the addition of a new employee (time clock) :
Create entitiy
Script: add user

in a global sense, I want to automate all working processes in SambaPOS - to all the typical actions happened without my intervention

@@SQL syntax is used by custom reports module to create reports with SQL. You can use sql.ExecSql('<script>') JS function to execute SQL Scripts.

By the way we’re slowly adding corresponding API methods for such functions. Discussing use cases & requirements with community will result with better solutions.

still I can not get it to work
please if not more difficult, show an example, I add a line to the base with help sql query.

many of the features that I try to do very subjective (highly specialized).
I do not think that every option should be implemented via the API.
even the most feature (add new employee Time clock) I will be realized in two ways for different cafes:

  1. First there is the bar code scanner and prepared cards with bar codes
    this manager will have to enter in the name of the employee his payrate and scan a card with a bar code (pincode).

2,in the other do not have Сards with bar codes, so there manager after will have to enter in the name of the employee his payrate, automation print barcode with Pin ( {RANDOM:X}).

I think a good solution would be to create wiki documents for v5, so as to find information on the forum takes a lot of hours

New Features will be available in Release forum category and here is the jscript api repository


Here is the wiki page feel free to update it if you wish.


Can you explain what you mean?

The API is being developed to do more advanced configurations and operations without the need to directly edit the database. Even if you researched and know it wont hurt anything anytime you manually edit the database you run risk of eventually causing harm. For example what if in a future update the way Users are stored is changed? If your using the API you wont have to worry but if your directly editing database then you would need to correct your SQL before someone runs it.

By the way you have given some good hints but you never really explained what your doing. I assume your using one of the Time Clock tutorials and your automating adding employees?

I mean, why bother community functions that I will use only me.

as this type:Hey, Emre, add the button that will call me a taxi to the end of the day.(ironically)

essentially the button can be realized, but why is it the community if it will use only am I?

the account that you are right, but would first ascertain in practice whether the function to make it into a discussion community.

I can read, but can not update the information.

  • now there is very little information for advanced users

Yes unfortunately the community does not contribute much to the wiki.

Most of the advancement of Sambapos happened because people discussed setups specific to their need. If you don’t explain the need how can we help solve the problem?

Someone else might want a button to call a cab. Or they might take that idea and make it do something else which leads to a new feature.

My point is if you explain what your doing we can recommend ideas.


I am surprised it does not throw an error, but the [Name] field is a varchar, so you cannot insert t5tu into that field without surrounding it with single quotes…

INSERT INTO [Users] ([PinCode], [Name], [UserRole_Id]) VALUES (7777775, 't5tu', 4)

You should also practice using SSMS to see if your query is valid before trying to code it into SambaPOS. You should find that SSMS throws an error with your query, but not when you use the one I provided.

1 Like