How to write custom condition code
Scrips' condition is a code that checks if that current transaction/ticket match some condition(s) and says to RT to run or skip scrip action.
When you write a custom condition you have access to the same objects as scrip action has, so its worth it to read basics section of WriteCustomAction article.
Major objects accessors are:
$self->TransactionObj # returns the current transaction object $self->TicketObj # returns the current ticket object $self->TemplateObj # returns the current template object
Whatever the test you do in your condition, you just have to return true value (like 1) on success or false (like 0 or undef) to abort the scrip action. Below a very simple condition that you can copy to the RT web interface if you choose
User Defined condition when you create a new scrip condition:
# get ticket object my $ticket = $self->TicketObj; # don't do anything if ticket is resolved return 0 if $ticket->Status eq 'resolved'; # otherwise run scrip action return 1;
Transaction object is most used object in conditions as it describes what's happened with the ticket just a few ticks ago.
Most important properties of the transaction object are
Another way to add conditions to RT
See NotResolved for another way of adding Conditions to RT