Recall & Clone (Customer) Last Ticket

This Tutorial shows how you can store, recall, and clone a previous Ticket. It works from the Ticket Explorer, or in the case of a Customer Entity, it will allow for cloning of that Customer’s last Ticket.

:thumbsup: This Tutorial should work for SambaPOS V4 or V5

Quick Links

Automation Commands
Actions
Rules
DB Tools
Updates


FLOW

Load & Clone a Ticket that has Customer Entity:

Clone a Ticket that has no Customer Entity:

2 Likes

Automation Commands

LT Clone Ticket [no Category] (Automation Command)

Name: LT Clone Ticket
Category:
Button Header: Clone\rTicket
Color: #FFC0504D
Font Size: 26
Confirmation: None
Values (0): (none)
Navigation Settings
Symbol:
Image:
Auto Refresh: 0
Tile Cache: 0
Navigation Module:
Nav Module Parameter:
Template: ```

</details>


<details>
<summary><b><u>Mappings</u></b></summary><table><tr><td><b>Terminal</b> </td><td><b>User Role</b> </td><td><b>Department</b> </td><td><b>Ticket Type</b> </td><td><b>Enabled States</b> </td><td><b>Visible States</b> </td><td><b>Visibility</b> </td></tr><tr><td><code>*</code></td><td><code>*</code></td><td><code>*</code></td><td><code>*</code></td><td><code></code></td><td><code>Status=Paid</code></td><td><code>Ticket</code></td></tr></table></details>


----------

<img src="/uploads/default/original/3X/9/0/90b0dbc368cbdecdeafdef9a408045c85a423e8f.png" width="364" height="500">

>## LT Display Last Ticket `[no Category]` (Automation Command) ##
<table><tr><td><b>Name:</b> </td><td><code>LT Display Last Ticket</code></td></tr><tr><td><b>Category:</b> </td><td><code></code></td></tr><tr><td><b>Button Header:</b> </td><td><code>Display Last\rSettled Ticket</code></td></tr><tr><td><b>Color:</b> </td><td><code>#FFC0504D</code></td></tr><tr><td><b>Font Size:</b> </td><td><code>26</code></td></tr><tr><td><b>Confirmation:</b> </td><td><code>None</code></td></tr></table>
<b>Values (0):</b> <i>(none)</i>


<details>
<summary><b><u>Navigation Settings</u></b></summary><table><tr><td><b>Symbol:</b> </td><td><code> </code></td></tr><tr><td><b>Image:</b> </td><td><code> </code></td></tr><tr><td><b>Auto Refresh:</b> </td><td><code>0</code></td></tr><tr><td><b>Tile Cache:</b> </td><td><code>0</code></td></tr><tr><td><b>Navigation Module:</b> </td><td><code> </code></td></tr><tr><td><b>Nav Module Parameter:</b> </td><td><code> </code></td></tr></table>
<b>Template:</b>

</details>


<details>
<summary><b><u>Mappings</u></b></summary><table><tr><td><b>Terminal</b> </td><td><b>User Role</b> </td><td><b>Department</b> </td><td><b>Ticket Type</b> </td><td><b>Enabled States</b> </td><td><b>Visible States</b> </td><td><b>Visibility</b> </td></tr><tr><td><code>*</code></td><td><code>*</code></td><td><code>*</code></td><td><code>*</code></td><td><code></code></td><td><code>Status=New</code></td><td><code>Ticket</code></td></tr></table></details>

Actions

LT Show Message [Show Message] (Action)

Action Name: LT Show Message
Action Type: Show Message

Parameters:

Message: [:MessageToDisplay]

LT Create Ticket Clone [Create Ticket] (Action)

Action Name: LT Create Ticket Clone
Action Type: Create Ticket

Parameters:

Clone Current Ticket: True
Clone All Orders: True

LT Display Ticket [Display Ticket] (Action)

Action Name: LT Display Ticket
Action Type: Display Ticket

Parameters:

Ticket Id: [:ticketId]

LT Load Entity by Search [Load Enitiy] (Action)

Action Name: LT Load Entity by Search
Action Type: Load Enitiy

Parameters:

Entity Type Name: [:entityTypeName]
Entity Name: [:entityName]
Entity Search Value: [:searchValue]

LT Store CLastTicketId in Memory [Update Program Setting] (Action)

Action Name: LT Store CLastTicketId in Memory
Action Type: Update Program Setting

Parameters:

Setting Name: [:customerName]_CLastTicketId
Setting Value: [:ticketId]
Update Type: Update
Is Local: True

LT Update Entity State CLastTicketId [Update Entity State] (Action)

Action Name: LT Update Entity State CLastTicketId
Action Type: Update Entity State

Parameters:

Entity Type Name: Customers
Entity Name: [:customerName]
Entity State Name: CLastTicketId
Current State:
Entity State: [:ticketId]
Quantity Exp:

Rules

LT Display Last Customer Ticket [Automation Command Executed] (Rule)

Rule Name: LT Display Last Customer Ticket
Event Name: Automation Command Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Automation Command NameEqualsLT Display Last Ticket

Actions (2):

LT Show Message

Constraint: ‘{SETTING:{ENTITY NAME:Customers}_CLastTicketId}’ == ‘’

MessageToDisplay: Cannot find Previous Ticket for\r{ENTITY NAME:Customers}\r{ENTITY NAME:Tables}
LT Display Ticket

Constraint: ‘{SETTING:{ENTITY NAME:Customers}_CLastTicketId}’ != ‘’

ticketId: [=TN('{SETTING:{ENTITY NAME:Customers}_CLastTicketId}')]

Mappings

Mappings
Terminal User Role Department Ticket Type
****

LT Clone Ticket [Automation Command Executed] (Rule)

Rule Name: LT Clone Ticket
Event Name: Automation Command Executed
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Automation Command NameEqualsLT Clone Ticket

Actions (1):

LT Create Ticket Clone

Constraint: (none)

Mappings

Mappings
Terminal User Role Department Ticket Type
****

LT Entity Selected - Load CLastTicketId from Entity State and Store in Memory [Entity Selected] (Rule)

Rule Name: LT Entity Selected - Load CLastTicketId from Entity State and Store in Memory
Event Name: Entity Selected
Rule Tags:
Custom Constraint List (1):
Execute Rule if: Matches
Entity Type NameEqualsCustomers

Actions (2):

LT Load Entity by Search

Constraint: (none)

entityTypeName: Customers
entityName: [:EntityName]
searchValue:
LT Store CLastTicketId in Memory

Constraint: (none)

customerName: [:EntityName]
ticketId: {ENTITY STATE:CLastTicketId}

Mappings

Mappings
Terminal User Role Department Ticket Type
****

LT Ticket Closing - Store Entity State CLastTicketId [Ticket Closing] (Rule)

Rule Name: LT Ticket Closing - Store Entity State CLastTicketId
Event Name: Ticket Closing
Rule Tags:
Custom Constraint List (3):
Execute Rule if: Matches
{TICKET STATE:Status}EqualsPaid
[=TN('{TICKET TOTAL}')]Greater0
{ENTITY NAME:Customers}Is Not Null

Actions (1):

LT Update Entity State CLastTicketId

Constraint: (none)

customerName: {ENTITY NAME:Customers}
ticketId: [=TN('{TICKET ID}')]

Mappings

Mappings
Terminal User Role Department Ticket Type
****
2 Likes

DB Tools

Recall_and_Clone_Ticket.zip (1.5 KB)

… reserved for updates …

I thought this tutorial has been around for a while, as I’ve implemented it before. Has something changed, other than all the new screenshots?

He more than likely just updated it for v5. Previously it was archived in v4 and its slightly harder to browse those tutorials now considering the categories are hidden on first navigation.

1 Like

It has been around for a long time.

I simply updated it to add some small tweaks to make it more robust. It should work in V4 or V5.

This is “Method 2” from the original V4 Topic, but I removed that post from that thread and replaced it with a re-direct to this new Tutorial.

1 Like

I am not sure what the problem please have a look to the screen print below

I think the problem its from [:customerName] in the first image I think this because the primary field is phone in the second image

You didn’t show the rule but if you have historic orders where name used to be customer name and not primary (entity name) is now number it wouldn’t work.
Interesting to use program setting over a entity custom field for last ticket…
You would need to either update program sting names to numbers OR change the rule so it searches for entity data:name rather than entity name.

1 Like

sorry I don’t understand

What @JTRTech is saying is about what you mentioned:

The Rules search and set data for a Customer based on {ENTITY NAME:Customers} or [:EntityName]. So whenever you see one of those variables being used in the Rules, you might need to change that to use instead:

{ENTITY DATA:Customers:Phone}

But to be sure, show a screenshot of your Customer Entity Type configuration of the Custom Data Fields, and a screenshot of one of the Customers to see what type of data is stored in each field.

Ok, so your Primary Field is “Phone”. That means {ENTITY NAME:Customers} or [:EntityName] used in the Rules will show you the Customer Phone Number, and {ENTITY DATA:Customers:Name} can be used to display the Custom Data field called “Name” which contains the Customer Name.

I think the issue is that your Entity Type Name is not “Customers”… it is " Customers E T ". So in your Rules, anywhere you see this:

{ENTITY NAME:Customers}

… you need to change it to this:

{ENTITY NAME:Customers E T}

For example…

RULE: LT Display Last Customer Ticket

Constraint: '{SETTING:{ENTITY NAME:Customers}_CLastTicketId}' == ''
CHANGETO: '{SETTING:{ENTITY NAME:Customers E T}_CLastTicketId}' == ''
MessageToDisplay: Cannot find Previous Ticket for\r{ENTITY NAME:Customers}\r{ENTITY NAME:Tables}
CHANGETO: Cannot find Previous Ticket for\r{ENTITY NAME:Customers E T}\r{ENTITY NAME:Tables}

Constraint: '{SETTING:{ENTITY NAME:Customers}_CLastTicketId}' != ''
CHANGETO: '{SETTING:{ENTITY NAME:Customers E T}_CLastTicketId}' != ''
ticketId: [=TN('{SETTING:{ENTITY NAME:Customers}_CLastTicketId}')]
CHANGETO: [=TN('{SETTING:{ENTITY NAME:Customers E T}_CLastTicketId}')]


RULE: LT Entity Selected - Load CLastTicketId from Entity State and Store in Memory

entityTypeName: Customers
CHANGETO: Customers E T


RULE: LT Ticket Closing - Store Entity State CLastTicketId

Custom Constraint: {ENTITY NAME:Customers} Is Not Null
CHANGETO: {ENTITY NAME:Customers E T} Is Not Null

customerName: {ENTITY NAME:Customers}
CHANGETO:: {ENTITY NAME:Customers E T}


1 Like

still not working i make sure that its > Customers E T

what i think maybe because of custom field format ### ## ### ###

when the samba try to find the tiket the format of the phone

I think no Ticket Number has ever been stored to the Entity because the Rules were not working as expected to be able to store the Ticket Number in the Entity State.

Try creating a Ticket for a Customer and Settle it. This is when the Ticket Id is stored in the Entity’s State named CLastTicketId.

Then select the same Customer again, and try to Load Last Ticket.