Transaction: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(5 intermediate revisions by the same user not shown)
Line 5: Line 5:
Common transactions are [[Comment]]s and [[Correspondence]]
Common transactions are [[Comment]]s and [[Correspondence]]


All types of transaction from <tt>lib/RT/Transaction.pm</tt>:
All types of transaction from <tt>[https://docs.bestpractical.com/rt/5.0.5/RT/Transaction.html lib/RT/Transaction.pm]</tt>:
*Create
*Create
*Enabled
*Enabled
Line 16: Line 16:
*Forward Transaction
*Forward Transaction
*Forward Ticket
*Forward Ticket
*CommentEmailRecord
*CommentEmailRecord &ndash; Outgoing email about a comment recorded
*EmailRecord &ndash; is set when RT is sending outgoing notification (correspondence, comment). Also if crontool is used.
*EmailRecord &ndash; is set when RT is sending outgoing notification (correspondence, comment). Also if crontool is used.
*Correspond &ndash; is set when some user sends a correspondence
*Correspond &ndash; is set when some user sends a correspondence
Line 33: Line 33:
*Told
*Told
*Set (password, queue, date/time, owner)
*Set (password, queue, date/time, owner)
*Set-TimeWorked
*Set-TimeWorked (till RT 4.2, then deprecated in favor of "Set")
*PurgeTransaction
*PurgeTransaction
*AddReminder
*AddReminder
Line 40: Line 40:


====Usage====
====Usage====
In scrips you can for example use it like this in custom contition:
Use <tt>$self->TransactionObj->Field</tt> to get the actual value of the specified type. For example:
<source lang="perl"><pre>
if ($self->TransactionObj->Type eq "CustomField") {print $self->TransactionObj->Field;}
</pre></source>
gives you the ID of currently processed CustomField.


Another example of scrip custom condition:
<source lang="perl"><pre>
<source lang="perl"><pre>
# On Create or Queue change
# On Create or Queue change
return 0 unless (($self->TransactionObj->Type eq "Create") || ($self->TransactionObj->Type eq "Set" && $self->TransactionObj->Field eq "Queue"));
return 0 unless (($self->TransactionObj->Type eq "Create") || ($self->TransactionObj->Type eq "Set" && $self->TransactionObj->Field eq "Queue"));
</pre></source>
==== Transaction record in history ====
You can avoid recording a transaction in a history for whatever reason like this:
<source lang="perl"><pre>
my $CustomField = $self->TicketObj->LoadCustomFieldByIdentifier("Some CF");
$self->TicketObj->AddCustomFieldValue(Field => $CustomField->Id, Value => 'Some Value', RecordTransaction => 0);
</pre></source>
</pre></source>

Latest revision as of 05:53, 5 January 2024

A Transaction in RT is anything that happens to a Ticket.

RT logs each transaction in the history of the ticket, and Scrips may also be attached to all or to certain kinds of transactions.

Common transactions are Comments and Correspondence

All types of transaction from lib/RT/Transaction.pm:

  • Create
  • Enabled
  • Disabled
  • Status
  • SystemError
  • AttachmentTruncate
  • AttachmentDrop
  • AttachmentError
  • Forward Transaction
  • Forward Ticket
  • CommentEmailRecord – Outgoing email about a comment recorded
  • EmailRecord – is set when RT is sending outgoing notification (correspondence, comment). Also if crontool is used.
  • Correspond – is set when some user sends a correspondence
  • Comment – is set when some user sends a comment
  • CustomField
  • Untake
  • Take
  • Force (forced owner change)
  • Steal
  • Give
  • AddWatcher
  • DelWatcher
  • Subject
  • Addlink
  • DeleteLink
  • Told
  • Set (password, queue, date/time, owner)
  • Set-TimeWorked (till RT 4.2, then deprecated in favor of "Set")
  • PurgeTransaction
  • AddReminder
  • OpenReminder
  • ResolveReminder

Usage

Use $self->TransactionObj->Field to get the actual value of the specified type. For example:

<pre>
if ($self->TransactionObj->Type eq "CustomField") {print $self->TransactionObj->Field;}
</pre>

gives you the ID of currently processed CustomField.

Another example of scrip custom condition:

<pre>
# On Create or Queue change
return 0 unless (($self->TransactionObj->Type eq "Create") || ($self->TransactionObj->Type eq "Set" && $self->TransactionObj->Field eq "Queue"));
</pre>

Transaction record in history

You can avoid recording a transaction in a history for whatever reason like this:

<pre>
my $CustomField = $self->TicketObj->LoadCustomFieldByIdentifier("Some CF");
$self->TicketObj->AddCustomFieldValue(Field => $CustomField->Id, Value => 'Some Value', RecordTransaction => 0);
</pre>