Actions, Rules & Automation Commands Explanation

Ok. So far i have managed to generate a voucher or coupon at the correct point of time. what i need now is to get the Voucher ID from the Create action to that i can add that the ticket to be able to print it with the bill.

However i cant seem to figure out how to get the Voucher ID from the Create Entity Action and add that to the Ticket.

That was what I was saying.
On your crate coupon button or a confirmation ask question if you prefer it triggers one command rule which has an execute automation command action.
That action has a command value of the random/unique id and the command name triggers a seccond rule which creates entity with that id, then you add a action to select that entity using the command value for the name, then additional update entity actions using command value again for the entity name and using whatever source you need for the update data.
For description use [?Description] which will show a popup with keyboard.
Will demo in half hour for you.

How to use Constraints in an action?

I have a rule when an automation command is executed [Add Deliverer to ticket] At this point i need to make a check if the total amount is more than 1000.

For testing i added a Show Message box, and added {TICKET TOTAL} > 1000 but it doesn’t seem to work

In the message box, {TICKET TOTAL} displays the correct amount. but the same thing in constraints fails to have an affect.

I have tried these for Constrains already:
{:TICKET TOTAL} > 1000
[:TICKET TOTAL] > 1000

{TICKET TOTAL} >= 1000
{:TICKET TOTAL} >= 1000
[TICKET TOTAL] >= 1000
[:TICKET TOTAL] >= 1000

Even tried without spaces… without any success…

Firstly thats a bad place to put that as in theory the ticket was closed in the previous action :slight_smile:

When using > or < you should always TN the tag to ensure it is returned as a number not a string TN(’{TICKET TOTAL}’)
Additionally I have always had difficulties getting larger/smaller or = to to work (probably just me) but I opted to stick to just >/< and change the value;

TN('{TICKET TOTAL}') > 999

Where do you intend to put this?

lol! Fair point on the Action sequence! :slight_smile:

Ideally thats my trigger to generate the Vouchers depending on how much the client spent. After generating the voucher, it needs to be assigned to the ticket in order to print with the Customer Bill.

Since this is a purely delivery setup, the idea is to generate the voucher when a deliverer is assigned, print the customer bill and voucher, hand it over to the delivery guy.

When the delivery guy returns, we close the ticket.

*I tried the TN() thing and it doesn’t seem to work for some reason. Output shows TN(‘931.00’)

It seems our office building needs to run some electrical maintenance, and we will have to shut down our server overnight. So i’ve got about 30 minutes more here until i shut everything down for the night :frowning:

Sorry to put you on overnight holds…really appreciate you helping us out JR!

In the message it might be looking at the TN as text rather than a function… not sure…
You might want to split the rule if that’s the case as there might be some issues with it printing before the coupon entity etc is made.
The first rule being a starter command having two execute automation command actions;
Evaluate Coupon with TN(’{TICKET TOTAL}’) > 999 constraint which fires the rule to create the coupon and add to ticket.
Deliverer Command with no constraint but set to background = true so that it waits for other rules to finish before firing allowing the other action to fire if needed and its rule to happen before doing the deliverer command.
That make sense?

Makes Sense… i’ll try to move things to a trigger prior to this and see how things go.
Anyways, time to shut this down now…

Will touch base tomorrow, will let you know of my progress. :slight_smile:

Have a good day!
Thanks again.

Need to wrap that in an expression, as such:

[=TN('{TICKET TOTAL}')] > 999

The [= ... ] part is an expression that evaluates the data.

1 Like

Thanks QMcKay, [=TN(’{TICKET TOTAL}’)] > 999 did work. But not on the custom constraint box on the Action Item.

So, i created a new rule, triggered it on Entity Deliverer Change and check the net amount using that condition. Works perfectly and Voucher was generated with all the right fields including the Ticket number that it was issued with.

Next issue i landed up on now is how to load this newly created Voucher and assign it to the Ticket for printing.

I created a Load Voucher Action

and an Update Ticket Entity to assign the voucher to the ticket.

my Rule is:

Im assuming my problem is the way im searching for the Entity. What are your suggestions?
‘Creation Ticket Id’ thats the name of the field that stores the Ticket ID.

Already double checked with the generated vouchers, ticket id is correct.

You have mentioned ticket ID and used ticket number at least twice… you havent mixed them up along the way have you?

ok yeah… im using the {TICKET NUMBER} to generate the voucher, so i’d need the same to find that voucher and assign to the ticket.

Still think your going about it wrong way in my mind. Although I have never used the search value for changing entity only used the actual name.
If you triggered the creating of the voucher using execute automation command with a command value of {RANDOM} or whatever your using to generate the voucher code. That way you can very specifically name the entity rather than search.
Also you can use the change ticket entity action to also create setting can create entity to true.

ok yeah! if the search doesnt work, i could use the TICKET NUMBER to have the Entity Name for Voucher as that would always be Unique.

So Ideally, ticket numbers never repeat… that right ?

or is there {TICKET ID} that is a unique ID which i could use as Voucher Primary Field ?

Both will be unique, ID is not generated until ticket submission/closing so in theory should be sequential unlike ticket number excluding if you void all orders after closing.

No need to load entity first. Just the Change Ticket Entity action should be enough. Load Entity action is meant for automation outside of tickets where it does not have access to Entities. Tickets do have access to Entities. You may need to refresh ticket to see the Entity Change.

Ok works now!

So i used the TICKET ID to identify the Voucher and load into the ticket.

however, now there is another strange thing going on…
Since im testing, i tried to delete the vouchers through the entities list screen, but i cant because they are still in use by the tickets.
The tickets have already been settled. any clue?

do i have to remove the entities from the ticket before settling to be able to delete them?

Yea you cant delete them if they are linked to a ticket whether the ticket is open or settled it doesnt matter, that entity is still saved on the ticket in the database

OK. I dont mind crowding up the DB for the moment. But, when we are going live, it is safe to zero all accounts following this ?

There is no reason to delete data from the database. The database can handle hundreds of thousands if not millions of transactions with virtually no performance hit.

i need to zero everything because right now im testing and developing, will have to get rid of all these transactions and set everything to 0 when we put this to real use.