im no script guru JTR lol.
annoyingly I cant find the thread i found the other day which gave the correct way of retreiving entity data from an unselected entity…
edit, found: Retrieve entity balances despite changing name
im no script guru JTR lol.
annoyingly I cant find the thread i found the other day which gave the correct way of retreiving entity data from an unselected entity…
edit, found: Retrieve entity balances despite changing name
You need to use the load entity action.
yeah, not sure itll work like that as i have this completely seperate from the POS. The POS loading up after will be a pain. Ill just have to do it manually I think
Matt
You could update via SQL or the GraphQL API (if update entity fields has been fixed).
I have a SQL script for updating an entity field. Let me know if you could use it.
Alternatively, you could serialise a list of Name/Value pairs to JSON then update the entity CustomData via SQL.
Appreciate the reply.
If the script would work with settings, {SETTING:EntityType} and {SETTING:ItemName} and be able to update then yes, I am very interested!
Matt
I’ve built a labelling system using the software which doesn’t use the POS part.
i have this completely seperate from the POS
{SETTING:EntityType} and {SETTING:ItemName}
I’m a bit confused. Is this all running in SambaPOS?
Yes, samba POS using entity screens
I don’t understand why you can’t use load entity action if it’s running inside sambapos.
That’s what was confusing me. If SambaPOS is running and it’s all happening inside it then existing automation capabilities should be sufficient to accomplish the task.
Is it possible to load an entity but not use the POS part?
Ill have to investigate more.
You dont want to execute Samba.Presentation.exe? So you are only using the db and graphql service?
For what im creating im only using entity screens
So you are running sambapos, you can use customer search widget for that or you can create a screen using report widget, see this topic: Customer Purchase History with Display/Print Ticket.
like Jesse mentioned, there are existing actions that you can use to work with entities.
Load entity does not open a ticket if that’s what you mean. It loads it in the background so you can do stuff to it.
Load entity is not the same as selecting one. Aka it will stay on the same screen.
ok, i never knew that…
Im going to test something today then, thanks. Ill send a link later to show what ive created.
SInce losing my businesses and become in stupid debt, ive had to think of other ideas.
I started up a fudge business and have a 5 star rated kitchen at home. This couldnt have started at a better time, opening an online store during covid, this has helped us a lot. I knew I was going to be using samba as a till again, I have a cater trailer in my drive im converting into a fudge store and will have a decent POS system.
Creating the labels using the label printers software was really unhelpful, having to load up each flavour individually and editing them manually, Dates, Weights and batch numbers. Its started to get tedious, especially when we got very busy. I then had a lightbulb moment and realised I could probably build something using Samba.
After I built it I showed another local business what I had made, and they were really interested in it too, they also loved the fact it could also work as a POS. Problem was, I created the system using hardcoded rules, actions and automation commands, templates and categories. So I started from scratch.
I thought it would be a great idea to run a setup wizard, so if any other businesses wanted the same then I could just use it running a wizard. Im not sure if anyone has ever tried this before, but after trying to work things out in my head with huge headaches and puzzlement, I succeeded.
The most impressive thing I worked out in the wizard was to link the categories with the printer templates. Madness.
Anyway, its version 5.3.4 if anyone would like to have a look. https://t.ly/NgBu
Passcode is 2211
Let me know what you think
Hi all.
I think I know what @GreatShakesBar was talking about… He has a bunch of entities (maybe customers, maybe tables, maybe staff) and he wants to set some types of custom data about various ones of these in an efficient way. This is what I have implemented to set details about our scuba diving clients - see example below
He has SambaPOS open so when he says “load the POS” he means he doesn’t want to have to use a standard customer search screen, find an entity, load a ticket (with the entity selected) then use this ticket not to actually build a ticket, but only for the purpose of giving him access to some Action Buttons to set these pieces of custom data.
As a dive shop, we have a lot of customers (entities) who each make various reservations (pre-order tickets) and we need to keep track of when size equipment they need. By storing this against the entity and not the ticket or order any time that customer returns their correct equipment can be recalled seamlessly.
Above you can see an entity screen that we use to set the equipment per customer. The “Table Mode” report on the left hand side shows all the divers we have with us today. Then, once you click a customer on the left this will set a program {SETTING:EQUIP-EntityName} and refresh all the widgets on the right hand side. The label widgets on the right hand side use the EntityName stored in {SETTING:EQUIP-EntityName} to display the current value and action buttons on the right hand side pass call a rule with the field to be set and the value of the field passed through the value to be set as the CommandValue. Within the rule itself the {SETTING:EQUIP-EntityName} can be access to update the data for the specific entity.
But, having today seen this “Load Entity” action, potentially some of this could be streamlined. However, to be honest there is a lot of other clever stuff* I am doing in all the rules anyway, so even if the Load Entity action might improve things a little, I will still want to hand off a lot of logic to the rules, rather than setting the value immediately from the button click.
*The clever stuff =
Sure…
You can see the report is in #Table mode, allowing values to be selected by the user.
The data for the report itself comes from some custom SQL script, but could easily be from standard {REPROT} tags.
Need that “Setting mappings” section configured correctly, so the value from column 2 gets set as a ProgramSetting each time a new line of the report is selected by the user.
All the label widgets on the right hand side have Property > Name set to “CurrentValue” therefore all of these labels refresh when a new line in the report is selected.
This is the config for setting the name label, but the other labels for each type of equipment work in a similar way.
{CALL:res.getCustomDataFromEntityName('Full Name','{SETTING:EQUIP-EntityName}')}
This tag runs some script which is part of my “Reservations” set of script, which uses the handler “res”
function getCustomDataFromEntityName(customData,entityName) {
entityName = entityName.replace("@","'+'@'+'");
var qry = "SELECT jsonValue FROM ENTITIES CROSS APPLY OPENJSON(CustomData) WITH (jsonName varchar(50) '$.Name', jsonValue varchar(50) '$.Value') jsonData WHERE jsonName = '"+customData+"' and Name = '"+entityName+"'";
var name = (sql.Query(qry).First);
return name;
}
I do this because the custom data is JSON based and I don’t think there are any tags that give us any easier access to this? BUt I might be wrong. All of my EntityName’s are their email addresses, since this will be unique.
This is the settings for the XL Male wetsuit button. Note that the “Value” which will become the “CommandValue” in the rule has a very specific format. The first -
denotes the separation between the field we want to set and the value we want to set it too. This is because I couldn’t find another reliable way of passing through two values to a rule. So I pass through one string which we will take care of splitting in a later step…
The field name and the field value are split by calling this scripts:
function equipType(input) {
// This is only going to work if equipment items DO NOT contain commas or dashes
var output = "";
output = input.substring(0,input.indexOf("-"));
return output;
}
function equipValue(input) {
var output = "";
output = input.substring(input.indexOf("-") +1, input.length);
return output;
}
You’ll notice some really long constraints on the execute command and Ask Question… The idea behind these is the following:
IF
the current value for the field that we are setting == “Issued”, Medical", “Print” or it is BLANK (Empty)
THEN
Run Part2 and set the field to the value of the button that was clicked
ELSE
Ask a question to confirm if we want to do this
Note: Part2 will always be run even after you click “Cancel” to the question, BUT, in Part2 we will check the value of what was pressed, if we pressed “Cancel” then we just won’t do anything
function getEntityTypeFromName(EntityName) {
EntityName = EntityName.replace("@","'+'@'+'");
return sql.Query("SELECT EntityTypes.Name FROM Entities INNER JOIN EntityTypes ON Entities.EntityTypeId = EntityTypes.Id where entities.Name = '"+EntityName+"'").First;
}
And that’s about it.
I am sure there is a lot that I could do to streamline this, but I put it all together one day when I was in a rush and never really had the need to re-visit it.
In writing it up here I can think of a few other tweaks I could try out, but honestly, If it works, don’t fix it.
Wow amazing, this is exactly what I need. Ill have a proper look on my next day off but this is very appreciated!
UPDATE:
Using my method might cause you problems with Out-Of-Memory exceptions, or at the very least you might find that SambaPOS slows down A LOT…
The issues are discussed in the following topics, but until this memory issue is addressed calling jScript to process some logic is probably not a good idea.
https://forum.sambapos.com/t/20423
It seems like these issues have been pretty well explained by @philbkk so hopefully they will be addressed by the team in the very near futue.