<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bduye</id>
	<title>Request Tracker Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bduye"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/wiki/Special:Contributions/Bduye"/>
	<updated>2026-08-22T09:05:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=User:Bduye&amp;diff=26305</id>
		<title>User:Bduye</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=User:Bduye&amp;diff=26305"/>
		<updated>2016-07-22T15:52:23Z</updated>

		<summary type="html">&lt;p&gt;Bduye: Created page with &amp;quot;Bruno Duyé page.  RT developper for [http://www.easter-eggs.com/ Easter Eggs]&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bruno Duyé page.&lt;br /&gt;
&lt;br /&gt;
RT developper for [http://www.easter-eggs.com/ Easter Eggs]&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=Privileged&amp;diff=26304</id>
		<title>Privileged</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=Privileged&amp;diff=26304"/>
		<updated>2016-07-22T15:47:04Z</updated>

		<summary type="html">&lt;p&gt;Bduye: Add precisions about privileged status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The group &#039;&#039;&#039;Privileged&#039;&#039;&#039; is one of the three groups for which RT manages the membership automatically. The other two are [[Unprivileged]] and [[Everyone]]. Every user is either a member of the Privileged group or of the Unprivileged group. Membership in the Privileged group means a user can be granted rights. To which one a user belongs can be set in the configuration screen for the user using the &#039;Let this user be granted rights&#039; checkbox.&lt;br /&gt;
&lt;br /&gt;
To resume:&lt;br /&gt;
* unprivileged -&amp;gt; access to [[SelfService]] only (whatever [[Rights]] are)&lt;br /&gt;
* privileged -&amp;gt; access are controlled by [[Rights]]&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=CustomField&amp;diff=26301</id>
		<title>CustomField</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=CustomField&amp;diff=26301"/>
		<updated>2016-07-21T11:05:38Z</updated>

		<summary type="html">&lt;p&gt;Bduye: &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &#039;&#039;&#039;Custom&#039;&#039;&#039;&#039;&#039;&#039;Field&#039;&#039;&#039; (CF) is a user defined property, usually of a [[Ticket]].&lt;br /&gt;
&lt;br /&gt;
Each custom field has a Name, Description and Type.&lt;br /&gt;
&lt;br /&gt;
RT supports the following CF types:&lt;br /&gt;
&lt;br /&gt;
* Select one value&lt;br /&gt;
* Select multiple values&lt;br /&gt;
* Enter one value&lt;br /&gt;
* Enter multiple values&lt;br /&gt;
* Fill in one text area (of which you can edit the size: [[ChangeCustomFieldTextAreaSize]])&lt;br /&gt;
* Fill in one wikitext area&lt;br /&gt;
* Fill in multiple wikitext areas&lt;br /&gt;
* Upload one image&lt;br /&gt;
* Upload multiple images&lt;br /&gt;
* Upload one file&lt;br /&gt;
* Upload multiple files&lt;br /&gt;
&lt;br /&gt;
You can define global CustomFields or specific to a [[Queue]] (see &amp;quot;CUSTOM FIELDS IN QUEUES&amp;quot; at [[ManualAdministration]]). They can apply to [[Ticket]], [[Group]], User or Ticket [[Transaction]]s.&lt;br /&gt;
&lt;br /&gt;
== How to set up a custom field in a nutshell ==&lt;br /&gt;
&lt;br /&gt;
==== First, create the Custom Field ====&lt;br /&gt;
&lt;br /&gt;
* Login as one with admin/superuser rights&lt;br /&gt;
* Go to Configuration &amp;amp;gt; [[CustomFields]]&lt;br /&gt;
* Click on Create&lt;br /&gt;
* Fill out the form appropriately and save changes&lt;br /&gt;
&lt;br /&gt;
==== Next, place the Custom Field where you want it ====&lt;br /&gt;
&lt;br /&gt;
* Go to Configuration &amp;amp;gt; Global &amp;amp;gt; [[CustomFields]]&lt;br /&gt;
* Choose where you want your [[CustomField]] to appear&lt;br /&gt;
* Select the [[CustomField]] you wish to apply and click &#039;Submit&#039;&lt;br /&gt;
&lt;br /&gt;
If you have installed RTFM you can also define CustomFields for [[RTFM]] Articles 848555157547&lt;br /&gt;
&lt;br /&gt;
== Modify CustomField Value ==&lt;br /&gt;
&lt;br /&gt;
=== RT 3.6 ===&lt;br /&gt;
&lt;br /&gt;
Use the bulk update option&lt;br /&gt;
&lt;br /&gt;
=== RT 3.4 ===&lt;br /&gt;
&lt;br /&gt;
Try the script below based on [http://use.perl.org/~Robrt/journal/25746 this journal entry]. This example renames &#039;[[TaskType]]&#039; values that were &#039;Sales Call&#039; to &#039;Prospect&#039; in the &#039;Sales&#039; queue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;#!/home/perl/bin/perl&lt;br /&gt;
 use strict;&lt;br /&gt;
 use warnings;&lt;br /&gt;
 use lib qw(../lib);&lt;br /&gt;
 use RT;&lt;br /&gt;
 use RT::Queues;&lt;br /&gt;
 use RT::Tickets;&lt;br /&gt;
 use Data::Dumper;&lt;br /&gt;
 &lt;br /&gt;
 # CONFIGURATION&lt;br /&gt;
 my $queue = &#039;Sales&#039;;&lt;br /&gt;
 my $cf_name = &#039;TaskType&#039;;&lt;br /&gt;
 my $old_value = &#039;Sales Call&#039;; # NB: This must be a valid value for the CF&lt;br /&gt;
 my $new_value = &#039;Prospect&#039;;&lt;br /&gt;
 # END CONFIGURATION&lt;br /&gt;
 &lt;br /&gt;
 RT::LoadConfig();&lt;br /&gt;
 RT::Init();&lt;br /&gt;
 my $tx = RT::Tickets-&amp;amp;gt;new($RT::SystemUser);&lt;br /&gt;
 my $cf = RT::CustomField-&amp;amp;gt;new($RT::SystemUser);&lt;br /&gt;
 my $q  = RT::Queue-&amp;amp;gt;new($RT::SystemUser);&lt;br /&gt;
 $tx-&amp;amp;gt;FromSQL(qq[queue=&amp;quot;$queue&amp;quot; and &amp;quot;cf.$queue.{$cf_name}&amp;quot; = &#039;$old_value&#039;]);&lt;br /&gt;
 $q-&amp;amp;gt;Load($queue);&lt;br /&gt;
 $cf-&amp;amp;gt;LoadByNameAndQueue(Queue =&amp;amp;gt; $q-&amp;amp;gt;Id, Name =&amp;amp;gt; $cf_name);&lt;br /&gt;
 unless( $cf-&amp;amp;gt;id ) {&lt;br /&gt;
   # queue 0 is special case and is a synonym for global queue&lt;br /&gt;
   $cf-&amp;amp;gt;LoadByNameAndQueue( Name =&amp;amp;gt; $cf_name, Queue =&amp;amp;gt; &#039;0&#039; );&lt;br /&gt;
 }&lt;br /&gt;
 unless( $cf-&amp;amp;gt;id ) {&lt;br /&gt;
   print &amp;quot;No field $cf_name in queue &amp;quot;. $q-&amp;amp;gt;Name;&lt;br /&gt;
   die &amp;quot;Could not load custom field&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 my $i=0;&lt;br /&gt;
 while (my $t = $tx-&amp;amp;gt;Next) {&lt;br /&gt;
   print &amp;quot;Processing record #&amp;quot; . ++$i . &amp;quot;\n&amp;quot;;&lt;br /&gt;
   my $type = $t-&amp;amp;gt;FirstCustomFieldValue($cf_name);&lt;br /&gt;
   print &amp;quot;Old Type = $type\n&amp;quot;;&lt;br /&gt;
   my ($ret, $msg) = $t-&amp;amp;gt;DeleteCustomFieldValue(&lt;br /&gt;
     Field =&amp;amp;gt; $cf-&amp;amp;gt;Id,&lt;br /&gt;
     Value =&amp;amp;gt; $type&lt;br /&gt;
   );&lt;br /&gt;
   die &amp;quot;Error deleting old value: $msg&amp;quot; unless $ret;&lt;br /&gt;
   $t-&amp;amp;gt;AddCustomFieldValue(&lt;br /&gt;
     Field =&amp;amp;gt; $cf-&amp;amp;gt;Id,&lt;br /&gt;
     Value =&amp;amp;gt; &#039;Prospect&#039;&lt;br /&gt;
   );&lt;br /&gt;
   $type = $t-&amp;amp;gt;FirstCustomFieldValue($cf_name);&lt;br /&gt;
   print &amp;quot;New Type = $type\n&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Simple Search Custom Field Values ==&lt;br /&gt;
&lt;br /&gt;
[[SearchCustomField]]&lt;br /&gt;
&lt;br /&gt;
== Custom Fields in Email Ticket Creation ==&lt;br /&gt;
&lt;br /&gt;
[[OnCreateCheckCF]]&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26300</id>
		<title>SuppressOutgoingMail</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26300"/>
		<updated>2016-07-21T10:42:48Z</updated>

		<summary type="html">&lt;p&gt;Bduye: &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Suppress All Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Steve Turner, March 3, 2006.&lt;br /&gt;
&lt;br /&gt;
This modification allows you to turn off ALL outgoing mail by using a new config variable. It is useful if you need to load tickets into a live system from a perl script (from a legacy system, for example) and you don&#039;t want RT to send mail for all the tickets you are loading.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s required is a new config variable (we called it $RT::[[MailSendingOff]]) and a minor mod to RT/lib/Action/[[SendEmail]].pm.&lt;br /&gt;
&lt;br /&gt;
If the config variable is true, no email will be sent by RT. Otherwise (config variable false or undef), mail will be sent as usual.&lt;br /&gt;
&lt;br /&gt;
Typically on our live system we have this variable set to 0 in [[RT SiteConfig|RT_SiteConfig]].pm so that RT&#039;s mail continues to work as expected for our users. In our data load scripts we turn off outgoing email for the duration of the load by coding this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $RT::MailSendingOff = 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The modification to [[SendEmail]],pm is at the top of the [[SendMessage]] method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sub SendMessage {&lt;br /&gt;
    my $self    = shift;&lt;br /&gt;
    my $MIMEObj = shift;&lt;br /&gt;
 &lt;br /&gt;
    my $msgid = $MIMEObj-&amp;amp;gt;head-&amp;amp;gt;get(&#039;Message-Id&#039;);&lt;br /&gt;
    chomp $msgid;&lt;br /&gt;
 &lt;br /&gt;
    # BEGIN MOD:&lt;br /&gt;
    # Do not send mail if the config says not to:&lt;br /&gt;
    if ($RT::MailSendingOff) {&lt;br /&gt;
        return (1);&lt;br /&gt;
    }&lt;br /&gt;
    # END MOD:&lt;br /&gt;
 &lt;br /&gt;
    $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot; #&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id . &amp;quot;/&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;id&lt;br /&gt;
        . &amp;quot; - Scrip &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;id . &amp;quot; &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;Description );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RT 4 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$RT::MailSendingOff = 1;&lt;br /&gt;
becomes&lt;br /&gt;
Set($MailSendingOff, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($RT::MailSendingOff) {&lt;br /&gt;
becomes&lt;br /&gt;
if (RT-&amp;gt;Config-&amp;gt;Get(&#039;MailSendingOff&#039;)) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Chris Adams, Jan 31, 2008&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The easiest way to suppress outgoing mail to a particular user (eg. noreply@example.com) is to remove the e-mail address from the autocreated user.&#039;&#039;&#039;  As long as their username is the same as their e-mail address, that user will still be used for incoming messages, but outgoing messages won&#039;t be sent.&lt;br /&gt;
&lt;br /&gt;
If you want finer-grained control, this modification allows you to specify certain addresses which will be removed when RT generates email by adding something like this to [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The mod applies to =RT/Action/[[SendEmail]].pm= just before it uses @blacklist to yank recipients - here&#039;s the patch against the Debian 3.6.1-4 package:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 --- SendEmail.pm	2008-01-31 11:51:15.344883000 -0800&lt;br /&gt;
 +++ /usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm	2008-01-31 11:54:30.000000000 -0800&lt;br /&gt;
 @@ -593,6 +593,15 @@&lt;br /&gt;
          push @blacklist, $attribute-&amp;amp;gt;Content;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
 +		# BEGIN SNL Modification: global squelch list&lt;br /&gt;
 +		#	This allows you to add a variable to RT_SiteConfig.pm containing addresses which will always be squelched:&lt;br /&gt;
 +		# Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
 +		if ($RT::SquelchList) {&lt;br /&gt;
 +      $RT::Logger-&amp;amp;gt;debug(&amp;quot;Using global squelch list: $RT::SquelchList\n&amp;quot;);&lt;br /&gt;
 +			push @blacklist, split(/,/, $RT::SquelchList);&lt;br /&gt;
 +		}&lt;br /&gt;
 +		# END SNL Modification: global squelch list&lt;br /&gt;
 +&lt;br /&gt;
      # Cycle through the people we&#039;re sending to and pull out anyone on the&lt;br /&gt;
      # system blacklist&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail by Regular Expression =&lt;br /&gt;
&lt;br /&gt;
Posted by Michael Brader April 22, 2009.&lt;br /&gt;
&lt;br /&gt;
This is similar to the above but removes the addresses if they match a regular expression. In [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 Set($SquelchRegexp, qr/noreply|sell-it-support|spam_master/);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The patch to to =RT/Action/[[SendEmail]].pm= (from 3.8.2) checks each address against the regexp after the blacklist check&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 --- local/lib/RT/Action/SendEmail.pm    2009-04-22 02:56:09.000000000 +0000&lt;br /&gt;
 +++ lib/RT/Action/SendEmail.pm  2009-01-12 23:18:46.000000000 +0000&lt;br /&gt;
 @@ -826,11 +826,6 @@&lt;br /&gt;
                  $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was blacklisted for outbound mail on this transaction. Skipping&amp;quot;);&lt;br /&gt;
                  next;&lt;br /&gt;
              }&lt;br /&gt;
 -           # Global Squelch Regexp&lt;br /&gt;
 -           if ($RT::SquelchRegexp and $addr =~ /$RT::SquelchRegexp/) {&lt;br /&gt;
 -                $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was squelched based on \$RT::SquelchRegexp in RT_SiteConfig.pm. Skipping&amp;quot;);&lt;br /&gt;
 -                next;&lt;br /&gt;
 -           }&lt;br /&gt;
              push @addrs, $addr;&lt;br /&gt;
          }&lt;br /&gt;
          @{ $self-&amp;amp;gt;{$type} } = @addrs;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress an email address by using a Scrip =&lt;br /&gt;
&lt;br /&gt;
If you have a need for certain email addresses to be suppressed in a particular queue (for example, tickets coming in from an automated system which uses an address which does not accept replies), you can create a Scrip to squelch the address. Use the &#039;&#039;&#039;On Create&#039;&#039;&#039; condition, and a &#039;&#039;&#039;User Defined&#039;&#039;&#039; action. The &#039;&#039;&#039;Prepare&#039;&#039;&#039; should be simply:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the &#039;&#039;&#039;Commit&#039;&#039;&#039; code should be something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 return 1 unless $self-&amp;gt;TicketObj-&amp;gt;IsWatcher( Type =&amp;gt; &#039;Requestor&#039;,&lt;br /&gt;
                                              Email =&amp;gt; &#039;noreply@example.com&#039; );&lt;br /&gt;
 $self-&amp;gt;TicketObj-&amp;gt;SquelchMailTo(&#039;noreply@example.com&#039;);&lt;br /&gt;
 return 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26299</id>
		<title>SuppressOutgoingMail</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26299"/>
		<updated>2016-07-21T10:42:23Z</updated>

		<summary type="html">&lt;p&gt;Bduye: &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Suppress All Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Steve Turner, March 3, 2006.&lt;br /&gt;
&lt;br /&gt;
This modification allows you to turn off ALL outgoing mail by using a new config variable. It is useful if you need to load tickets into a live system from a perl script (from a legacy system, for example) and you don&#039;t want RT to send mail for all the tickets you are loading.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s required is a new config variable (we called it $RT::[[MailSendingOff]]) and a minor mod to RT/lib/Action/[[SendEmail]].pm.&lt;br /&gt;
&lt;br /&gt;
If the config variable is true, no email will be sent by RT. Otherwise (config variable false or undef), mail will be sent as usual.&lt;br /&gt;
&lt;br /&gt;
Typically on our live system we have this variable set to 0 in [[RT SiteConfig|RT_SiteConfig]].pm so that RT&#039;s mail continues to work as expected for our users. In our data load scripts we turn off outgoing email for the duration of the load by coding this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $RT::MailSendingOff = 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The modification to [[SendEmail]],pm is at the top of the [[SendMessage]] method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sub SendMessage {&lt;br /&gt;
    my $self    = shift;&lt;br /&gt;
    my $MIMEObj = shift;&lt;br /&gt;
 &lt;br /&gt;
    my $msgid = $MIMEObj-&amp;amp;gt;head-&amp;amp;gt;get(&#039;Message-Id&#039;);&lt;br /&gt;
    chomp $msgid;&lt;br /&gt;
 &lt;br /&gt;
    # BEGIN MOD:&lt;br /&gt;
    # Do not send mail if the config says not to:&lt;br /&gt;
    if ($RT::MailSendingOff) {&lt;br /&gt;
        return (1);&lt;br /&gt;
    }&lt;br /&gt;
    # END MOD:&lt;br /&gt;
 &lt;br /&gt;
    $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot; #&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id . &amp;quot;/&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;id&lt;br /&gt;
        . &amp;quot; - Scrip &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;id . &amp;quot; &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;Description );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RT 4 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$RT::MailSendingOff = 1;&lt;br /&gt;
becomes&lt;br /&gt;
Set($MailSendingOff, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($RT::MailSendingOff) {&lt;br /&gt;
becomes&lt;br /&gt;
if (RT-&amp;gt;Config-&amp;gt;Get(&#039;MailSendingOff&#039;)) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Chris Adams, Jan 31, 2008&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The easiest way to suppress outgoing mail to a particular user (eg. noreply@example.com) is to remove the e-mail address from the autocreated user.&#039;&#039;&#039;  As long as their username is the same as their e-mail address, that user will still be used for incoming messages, but outgoing messages won&#039;t be sent.&lt;br /&gt;
&lt;br /&gt;
If you want finer-grained control, this modification allows you to specify certain addresses which will be removed when RT generates email by adding something like this to [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
&lt;br /&gt;
The mod applies to =RT/Action/[[SendEmail]].pm= just before it uses @blacklist to yank recipients - here&#039;s the patch against the Debian 3.6.1-4 package:&lt;br /&gt;
&lt;br /&gt;
 --- SendEmail.pm	2008-01-31 11:51:15.344883000 -0800&lt;br /&gt;
 +++ /usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm	2008-01-31 11:54:30.000000000 -0800&lt;br /&gt;
 @@ -593,6 +593,15 @@&lt;br /&gt;
          push @blacklist, $attribute-&amp;amp;gt;Content;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
 +		# BEGIN SNL Modification: global squelch list&lt;br /&gt;
 +		#	This allows you to add a variable to RT_SiteConfig.pm containing addresses which will always be squelched:&lt;br /&gt;
 +		# Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
 +		if ($RT::SquelchList) {&lt;br /&gt;
 +      $RT::Logger-&amp;amp;gt;debug(&amp;quot;Using global squelch list: $RT::SquelchList\n&amp;quot;);&lt;br /&gt;
 +			push @blacklist, split(/,/, $RT::SquelchList);&lt;br /&gt;
 +		}&lt;br /&gt;
 +		# END SNL Modification: global squelch list&lt;br /&gt;
 +&lt;br /&gt;
      # Cycle through the people we&#039;re sending to and pull out anyone on the&lt;br /&gt;
      # system blacklist&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail by Regular Expression =&lt;br /&gt;
&lt;br /&gt;
Posted by Michael Brader April 22, 2009.&lt;br /&gt;
&lt;br /&gt;
This is similar to the above but removes the addresses if they match a regular expression. In [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 Set($SquelchRegexp, qr/noreply|sell-it-support|spam_master/);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The patch to to =RT/Action/[[SendEmail]].pm= (from 3.8.2) checks each address against the regexp after the blacklist check&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 --- local/lib/RT/Action/SendEmail.pm    2009-04-22 02:56:09.000000000 +0000&lt;br /&gt;
 +++ lib/RT/Action/SendEmail.pm  2009-01-12 23:18:46.000000000 +0000&lt;br /&gt;
 @@ -826,11 +826,6 @@&lt;br /&gt;
                  $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was blacklisted for outbound mail on this transaction. Skipping&amp;quot;);&lt;br /&gt;
                  next;&lt;br /&gt;
              }&lt;br /&gt;
 -           # Global Squelch Regexp&lt;br /&gt;
 -           if ($RT::SquelchRegexp and $addr =~ /$RT::SquelchRegexp/) {&lt;br /&gt;
 -                $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was squelched based on \$RT::SquelchRegexp in RT_SiteConfig.pm. Skipping&amp;quot;);&lt;br /&gt;
 -                next;&lt;br /&gt;
 -           }&lt;br /&gt;
              push @addrs, $addr;&lt;br /&gt;
          }&lt;br /&gt;
          @{ $self-&amp;amp;gt;{$type} } = @addrs;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress an email address by using a Scrip =&lt;br /&gt;
&lt;br /&gt;
If you have a need for certain email addresses to be suppressed in a particular queue (for example, tickets coming in from an automated system which uses an address which does not accept replies), you can create a Scrip to squelch the address. Use the &#039;&#039;&#039;On Create&#039;&#039;&#039; condition, and a &#039;&#039;&#039;User Defined&#039;&#039;&#039; action. The &#039;&#039;&#039;Prepare&#039;&#039;&#039; should be simply:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the &#039;&#039;&#039;Commit&#039;&#039;&#039; code should be something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 return 1 unless $self-&amp;gt;TicketObj-&amp;gt;IsWatcher( Type =&amp;gt; &#039;Requestor&#039;,&lt;br /&gt;
                                              Email =&amp;gt; &#039;noreply@example.com&#039; );&lt;br /&gt;
 $self-&amp;gt;TicketObj-&amp;gt;SquelchMailTo(&#039;noreply@example.com&#039;);&lt;br /&gt;
 return 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26298</id>
		<title>SuppressOutgoingMail</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26298"/>
		<updated>2016-07-21T10:41:52Z</updated>

		<summary type="html">&lt;p&gt;Bduye: &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Suppress All Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Steve Turner, March 3, 2006.&lt;br /&gt;
&lt;br /&gt;
This modification allows you to turn off ALL outgoing mail by using a new config variable. It is useful if you need to load tickets into a live system from a perl script (from a legacy system, for example) and you don&#039;t want RT to send mail for all the tickets you are loading.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s required is a new config variable (we called it $RT::[[MailSendingOff]]) and a minor mod to RT/lib/Action/[[SendEmail]].pm.&lt;br /&gt;
&lt;br /&gt;
If the config variable is true, no email will be sent by RT. Otherwise (config variable false or undef), mail will be sent as usual.&lt;br /&gt;
&lt;br /&gt;
Typically on our live system we have this variable set to 0 in [[RT SiteConfig|RT_SiteConfig]].pm so that RT&#039;s mail continues to work as expected for our users. In our data load scripts we turn off outgoing email for the duration of the load by coding this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $RT::MailSendingOff = 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The modification to [[SendEmail]],pm is at the top of the [[SendMessage]] method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sub SendMessage {&lt;br /&gt;
    my $self    = shift;&lt;br /&gt;
    my $MIMEObj = shift;&lt;br /&gt;
 &lt;br /&gt;
    my $msgid = $MIMEObj-&amp;amp;gt;head-&amp;amp;gt;get(&#039;Message-Id&#039;);&lt;br /&gt;
    chomp $msgid;&lt;br /&gt;
 &lt;br /&gt;
    # BEGIN MOD:&lt;br /&gt;
    # Do not send mail if the config says not to:&lt;br /&gt;
    if ($RT::MailSendingOff) {&lt;br /&gt;
        return (1);&lt;br /&gt;
    }&lt;br /&gt;
    # END MOD:&lt;br /&gt;
 &lt;br /&gt;
    $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot; #&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id . &amp;quot;/&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;id&lt;br /&gt;
        . &amp;quot; - Scrip &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;id . &amp;quot; &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;Description );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RT 4 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$RT::MailSendingOff = 1;&lt;br /&gt;
becomes&lt;br /&gt;
Set($MailSendingOff, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($RT::MailSendingOff) {&lt;br /&gt;
becomes&lt;br /&gt;
if (RT-&amp;gt;Config-&amp;gt;Get(&#039;MailSendingOff&#039;)) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Chris Adams, Jan 31, 2008&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The easiest way to suppress outgoing mail to a particular user (eg. noreply@example.com) is to remove the e-mail address from the autocreated user.&#039;&#039;&#039;  As long as their username is the same as their e-mail address, that user will still be used for incoming messages, but outgoing messages won&#039;t be sent.&lt;br /&gt;
&lt;br /&gt;
If you want finer-grained control, this modification allows you to specify certain addresses which will be removed when RT generates email by adding something like this to [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
&lt;br /&gt;
The mod applies to =RT/Action/[[SendEmail]].pm= just before it uses @blacklist to yank recipients - here&#039;s the patch against the Debian 3.6.1-4 package:&lt;br /&gt;
&lt;br /&gt;
 --- SendEmail.pm	2008-01-31 11:51:15.344883000 -0800&lt;br /&gt;
 +++ /usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm	2008-01-31 11:54:30.000000000 -0800&lt;br /&gt;
 @@ -593,6 +593,15 @@&lt;br /&gt;
          push @blacklist, $attribute-&amp;amp;gt;Content;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
 +		# BEGIN SNL Modification: global squelch list&lt;br /&gt;
 +		#	This allows you to add a variable to RT_SiteConfig.pm containing addresses which will always be squelched:&lt;br /&gt;
 +		# Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
 +		if ($RT::SquelchList) {&lt;br /&gt;
 +      $RT::Logger-&amp;amp;gt;debug(&amp;quot;Using global squelch list: $RT::SquelchList\n&amp;quot;);&lt;br /&gt;
 +			push @blacklist, split(/,/, $RT::SquelchList);&lt;br /&gt;
 +		}&lt;br /&gt;
 +		# END SNL Modification: global squelch list&lt;br /&gt;
 +&lt;br /&gt;
      # Cycle through the people we&#039;re sending to and pull out anyone on the&lt;br /&gt;
      # system blacklist&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail by Regular Expression =&lt;br /&gt;
&lt;br /&gt;
Posted by Michael Brader April 22, 2009.&lt;br /&gt;
&lt;br /&gt;
This is similar to the above but removes the addresses if they match a regular expression. In [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchRegexp, qr/noreply|sell-it-support|spam_master/);&lt;br /&gt;
&lt;br /&gt;
The patch to to =RT/Action/[[SendEmail]].pm= (from 3.8.2) checks each address against the regexp after the blacklist check&lt;br /&gt;
&lt;br /&gt;
 --- local/lib/RT/Action/SendEmail.pm    2009-04-22 02:56:09.000000000 +0000&lt;br /&gt;
 +++ lib/RT/Action/SendEmail.pm  2009-01-12 23:18:46.000000000 +0000&lt;br /&gt;
 @@ -826,11 +826,6 @@&lt;br /&gt;
                  $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was blacklisted for outbound mail on this transaction. Skipping&amp;quot;);&lt;br /&gt;
                  next;&lt;br /&gt;
              }&lt;br /&gt;
 -           # Global Squelch Regexp&lt;br /&gt;
 -           if ($RT::SquelchRegexp and $addr =~ /$RT::SquelchRegexp/) {&lt;br /&gt;
 -                $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was squelched based on \$RT::SquelchRegexp in RT_SiteConfig.pm. Skipping&amp;quot;);&lt;br /&gt;
 -                next;&lt;br /&gt;
 -           }&lt;br /&gt;
              push @addrs, $addr;&lt;br /&gt;
          }&lt;br /&gt;
          @{ $self-&amp;amp;gt;{$type} } = @addrs;&lt;br /&gt;
&lt;br /&gt;
= Suppress an email address by using a Scrip =&lt;br /&gt;
&lt;br /&gt;
If you have a need for certain email addresses to be suppressed in a particular queue (for example, tickets coming in from an automated system which uses an address which does not accept replies), you can create a Scrip to squelch the address. Use the &#039;&#039;&#039;On Create&#039;&#039;&#039; condition, and a &#039;&#039;&#039;User Defined&#039;&#039;&#039; action. The &#039;&#039;&#039;Prepare&#039;&#039;&#039; should be simply:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the &#039;&#039;&#039;Commit&#039;&#039;&#039; code should be something like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 return 1 unless $self-&amp;gt;TicketObj-&amp;gt;IsWatcher( Type =&amp;gt; &#039;Requestor&#039;,&lt;br /&gt;
                                              Email =&amp;gt; &#039;noreply@example.com&#039; );&lt;br /&gt;
 $self-&amp;gt;TicketObj-&amp;gt;SquelchMailTo(&#039;noreply@example.com&#039;);&lt;br /&gt;
 return 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26297</id>
		<title>SuppressOutgoingMail</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26297"/>
		<updated>2016-07-21T10:40:08Z</updated>

		<summary type="html">&lt;p&gt;Bduye: RT4 update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Suppress All Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Steve Turner, March 3, 2006.&lt;br /&gt;
&lt;br /&gt;
This modification allows you to turn off ALL outgoing mail by using a new config variable. It is useful if you need to load tickets into a live system from a perl script (from a legacy system, for example) and you don&#039;t want RT to send mail for all the tickets you are loading.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s required is a new config variable (we called it $RT::[[MailSendingOff]]) and a minor mod to RT/lib/Action/[[SendEmail]].pm.&lt;br /&gt;
&lt;br /&gt;
If the config variable is true, no email will be sent by RT. Otherwise (config variable false or undef), mail will be sent as usual.&lt;br /&gt;
&lt;br /&gt;
Typically on our live system we have this variable set to 0 in [[RT SiteConfig|RT_SiteConfig]].pm so that RT&#039;s mail continues to work as expected for our users. In our data load scripts we turn off outgoing email for the duration of the load by coding this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $RT::MailSendingOff = 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The modification to [[SendEmail]],pm is at the top of the [[SendMessage]] method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sub SendMessage {&lt;br /&gt;
    my $self    = shift;&lt;br /&gt;
    my $MIMEObj = shift;&lt;br /&gt;
 &lt;br /&gt;
    my $msgid = $MIMEObj-&amp;amp;gt;head-&amp;amp;gt;get(&#039;Message-Id&#039;);&lt;br /&gt;
    chomp $msgid;&lt;br /&gt;
 &lt;br /&gt;
    # BEGIN MOD:&lt;br /&gt;
    # Do not send mail if the config says not to:&lt;br /&gt;
    if ($RT::MailSendingOff) {&lt;br /&gt;
        return (1);&lt;br /&gt;
    }&lt;br /&gt;
    # END MOD:&lt;br /&gt;
 &lt;br /&gt;
    $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot; #&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id . &amp;quot;/&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;id&lt;br /&gt;
        . &amp;quot; - Scrip &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;id . &amp;quot; &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;Description );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== RT 4 ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$RT::MailSendingOff = 1;&lt;br /&gt;
becomes&lt;br /&gt;
Set($MailSendingOff, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($RT::MailSendingOff) {&lt;br /&gt;
becomes&lt;br /&gt;
if (RT-&amp;gt;Config-&amp;gt;Get(&#039;MailSendingOff&#039;)) {&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Chris Adams, Jan 31, 2008&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The easiest way to suppress outgoing mail to a particular user (eg. noreply@example.com) is to remove the e-mail address from the autocreated user.&#039;&#039;&#039;  As long as their username is the same as their e-mail address, that user will still be used for incoming messages, but outgoing messages won&#039;t be sent.&lt;br /&gt;
&lt;br /&gt;
If you want finer-grained control, this modification allows you to specify certain addresses which will be removed when RT generates email by adding something like this to [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
&lt;br /&gt;
The mod applies to =RT/Action/[[SendEmail]].pm= just before it uses @blacklist to yank recipients - here&#039;s the patch against the Debian 3.6.1-4 package:&lt;br /&gt;
&lt;br /&gt;
 --- SendEmail.pm	2008-01-31 11:51:15.344883000 -0800&lt;br /&gt;
 +++ /usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm	2008-01-31 11:54:30.000000000 -0800&lt;br /&gt;
 @@ -593,6 +593,15 @@&lt;br /&gt;
          push @blacklist, $attribute-&amp;amp;gt;Content;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
 +		# BEGIN SNL Modification: global squelch list&lt;br /&gt;
 +		#	This allows you to add a variable to RT_SiteConfig.pm containing addresses which will always be squelched:&lt;br /&gt;
 +		# Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
 +		if ($RT::SquelchList) {&lt;br /&gt;
 +      $RT::Logger-&amp;amp;gt;debug(&amp;quot;Using global squelch list: $RT::SquelchList\n&amp;quot;);&lt;br /&gt;
 +			push @blacklist, split(/,/, $RT::SquelchList);&lt;br /&gt;
 +		}&lt;br /&gt;
 +		# END SNL Modification: global squelch list&lt;br /&gt;
 +&lt;br /&gt;
      # Cycle through the people we&#039;re sending to and pull out anyone on the&lt;br /&gt;
      # system blacklist&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail by Regular Expression =&lt;br /&gt;
&lt;br /&gt;
Posted by Michael Brader April 22, 2009.&lt;br /&gt;
&lt;br /&gt;
This is similar to the above but removes the addresses if they match a regular expression. In [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchRegexp, qr/noreply|sell-it-support|spam_master/);&lt;br /&gt;
&lt;br /&gt;
The patch to to =RT/Action/[[SendEmail]].pm= (from 3.8.2) checks each address against the regexp after the blacklist check&lt;br /&gt;
&lt;br /&gt;
 --- local/lib/RT/Action/SendEmail.pm    2009-04-22 02:56:09.000000000 +0000&lt;br /&gt;
 +++ lib/RT/Action/SendEmail.pm  2009-01-12 23:18:46.000000000 +0000&lt;br /&gt;
 @@ -826,11 +826,6 @@&lt;br /&gt;
                  $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was blacklisted for outbound mail on this transaction. Skipping&amp;quot;);&lt;br /&gt;
                  next;&lt;br /&gt;
              }&lt;br /&gt;
 -           # Global Squelch Regexp&lt;br /&gt;
 -           if ($RT::SquelchRegexp and $addr =~ /$RT::SquelchRegexp/) {&lt;br /&gt;
 -                $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was squelched based on \$RT::SquelchRegexp in RT_SiteConfig.pm. Skipping&amp;quot;);&lt;br /&gt;
 -                next;&lt;br /&gt;
 -           }&lt;br /&gt;
              push @addrs, $addr;&lt;br /&gt;
          }&lt;br /&gt;
          @{ $self-&amp;amp;gt;{$type} } = @addrs;&lt;br /&gt;
&lt;br /&gt;
= Suppress an email address by using a Scrip =&lt;br /&gt;
&lt;br /&gt;
If you have a need for certain email addresses to be suppressed in a particular queue (for example, tickets coming in from an automated system which uses an address which does not accept replies), you can create a Scrip to squelch the address. Use the &#039;&#039;&#039;On Create&#039;&#039;&#039; condition, and a &#039;&#039;&#039;User Defined&#039;&#039;&#039; action. The &#039;&#039;&#039;Prepare&#039;&#039;&#039; should be simply:&lt;br /&gt;
&lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
and the &#039;&#039;&#039;Commit&#039;&#039;&#039; code should be something like:&lt;br /&gt;
&lt;br /&gt;
 return 1 unless $self-&amp;gt;TicketObj-&amp;gt;IsWatcher( Type =&amp;gt; &#039;Requestor&#039;,&lt;br /&gt;
                                              Email =&amp;gt; &#039;noreply@example.com&#039; );&lt;br /&gt;
 $self-&amp;gt;TicketObj-&amp;gt;SquelchMailTo(&#039;noreply@example.com&#039;);&lt;br /&gt;
 return 1;&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26296</id>
		<title>SuppressOutgoingMail</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SuppressOutgoingMail&amp;diff=26296"/>
		<updated>2016-07-21T10:24:08Z</updated>

		<summary type="html">&lt;p&gt;Bduye: /* Suppress All Outgoing Mail */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Suppress All Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Steve Turner, March 3, 2006.&lt;br /&gt;
&lt;br /&gt;
This modification allows you to turn off ALL outgoing mail by using a new config variable. It is useful if you need to load tickets into a live system from a perl script (from a legacy system, for example) and you don&#039;t want RT to send mail for all the tickets you are loading.&lt;br /&gt;
&lt;br /&gt;
All that&#039;s required is a new config variable (we called it $RT::[[MailSendingOff]]) and a minor mod to RT/lib/Action/[[SendEmail]].pm.&lt;br /&gt;
&lt;br /&gt;
If the config variable is true, no email will be sent by RT. Otherwise (config variable false or undef), mail will be sent as usual.&lt;br /&gt;
&lt;br /&gt;
Typically on our live system we have this variable set to 0 in [[RT SiteConfig|RT_SiteConfig]].pm so that RT&#039;s mail continues to work as expected for our users. In our data load scripts we turn off outgoing email for the duration of the load by coding this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $RT::MailSendingOff = 1;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The modification to [[SendEmail]],pm is at the top of the [[SendMessage]] method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 sub SendMessage {&lt;br /&gt;
    my $self    = shift;&lt;br /&gt;
    my $MIMEObj = shift;&lt;br /&gt;
 &lt;br /&gt;
    my $msgid = $MIMEObj-&amp;amp;gt;head-&amp;amp;gt;get(&#039;Message-Id&#039;);&lt;br /&gt;
    chomp $msgid;&lt;br /&gt;
 &lt;br /&gt;
    # BEGIN MOD:&lt;br /&gt;
    # Do not send mail if the config says not to:&lt;br /&gt;
    if ($RT::MailSendingOff) {&lt;br /&gt;
        return (1);&lt;br /&gt;
    }&lt;br /&gt;
    # END MOD:&lt;br /&gt;
 &lt;br /&gt;
    $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot; #&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id . &amp;quot;/&amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;id&lt;br /&gt;
        . &amp;quot; - Scrip &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;id . &amp;quot; &amp;quot;&lt;br /&gt;
        . $self-&amp;amp;gt;ScripObj-&amp;amp;gt;Description );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail =&lt;br /&gt;
&lt;br /&gt;
Posted by Chris Adams, Jan 31, 2008&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The easiest way to suppress outgoing mail to a particular user (eg. noreply@example.com) is to remove the e-mail address from the autocreated user.&#039;&#039;&#039;  As long as their username is the same as their e-mail address, that user will still be used for incoming messages, but outgoing messages won&#039;t be sent.&lt;br /&gt;
&lt;br /&gt;
If you want finer-grained control, this modification allows you to specify certain addresses which will be removed when RT generates email by adding something like this to [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
&lt;br /&gt;
The mod applies to =RT/Action/[[SendEmail]].pm= just before it uses @blacklist to yank recipients - here&#039;s the patch against the Debian 3.6.1-4 package:&lt;br /&gt;
&lt;br /&gt;
 --- SendEmail.pm	2008-01-31 11:51:15.344883000 -0800&lt;br /&gt;
 +++ /usr/share/request-tracker3.6/lib/RT/Action/SendEmail.pm	2008-01-31 11:54:30.000000000 -0800&lt;br /&gt;
 @@ -593,6 +593,15 @@&lt;br /&gt;
          push @blacklist, $attribute-&amp;amp;gt;Content;&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
 +		# BEGIN SNL Modification: global squelch list&lt;br /&gt;
 +		#	This allows you to add a variable to RT_SiteConfig.pm containing addresses which will always be squelched:&lt;br /&gt;
 +		# Set($SquelchList, &#039;root@example.edu,www-data@example.edu,nobody@example.edu&#039;);&lt;br /&gt;
 +		if ($RT::SquelchList) {&lt;br /&gt;
 +      $RT::Logger-&amp;amp;gt;debug(&amp;quot;Using global squelch list: $RT::SquelchList\n&amp;quot;);&lt;br /&gt;
 +			push @blacklist, split(/,/, $RT::SquelchList);&lt;br /&gt;
 +		}&lt;br /&gt;
 +		# END SNL Modification: global squelch list&lt;br /&gt;
 +&lt;br /&gt;
      # Cycle through the people we&#039;re sending to and pull out anyone on the&lt;br /&gt;
      # system blacklist&lt;br /&gt;
&lt;br /&gt;
= Suppress Some Outgoing Mail by Regular Expression =&lt;br /&gt;
&lt;br /&gt;
Posted by Michael Brader April 22, 2009.&lt;br /&gt;
&lt;br /&gt;
This is similar to the above but removes the addresses if they match a regular expression. In [[RT SiteConfig|RT_SiteConfig]].pm:&lt;br /&gt;
&lt;br /&gt;
 Set($SquelchRegexp, qr/noreply|sell-it-support|spam_master/);&lt;br /&gt;
&lt;br /&gt;
The patch to to =RT/Action/[[SendEmail]].pm= (from 3.8.2) checks each address against the regexp after the blacklist check&lt;br /&gt;
&lt;br /&gt;
 --- local/lib/RT/Action/SendEmail.pm    2009-04-22 02:56:09.000000000 +0000&lt;br /&gt;
 +++ lib/RT/Action/SendEmail.pm  2009-01-12 23:18:46.000000000 +0000&lt;br /&gt;
 @@ -826,11 +826,6 @@&lt;br /&gt;
                  $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was blacklisted for outbound mail on this transaction. Skipping&amp;quot;);&lt;br /&gt;
                  next;&lt;br /&gt;
              }&lt;br /&gt;
 -           # Global Squelch Regexp&lt;br /&gt;
 -           if ($RT::SquelchRegexp and $addr =~ /$RT::SquelchRegexp/) {&lt;br /&gt;
 -                $RT::Logger-&amp;amp;gt;info( $msgid . &amp;quot;$addr was squelched based on \$RT::SquelchRegexp in RT_SiteConfig.pm. Skipping&amp;quot;);&lt;br /&gt;
 -                next;&lt;br /&gt;
 -           }&lt;br /&gt;
              push @addrs, $addr;&lt;br /&gt;
          }&lt;br /&gt;
          @{ $self-&amp;amp;gt;{$type} } = @addrs;&lt;br /&gt;
&lt;br /&gt;
= Suppress an email address by using a Scrip =&lt;br /&gt;
&lt;br /&gt;
If you have a need for certain email addresses to be suppressed in a particular queue (for example, tickets coming in from an automated system which uses an address which does not accept replies), you can create a Scrip to squelch the address. Use the &#039;&#039;&#039;On Create&#039;&#039;&#039; condition, and a &#039;&#039;&#039;User Defined&#039;&#039;&#039; action. The &#039;&#039;&#039;Prepare&#039;&#039;&#039; should be simply:&lt;br /&gt;
&lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
and the &#039;&#039;&#039;Commit&#039;&#039;&#039; code should be something like:&lt;br /&gt;
&lt;br /&gt;
 return 1 unless $self-&amp;gt;TicketObj-&amp;gt;IsWatcher( Type =&amp;gt; &#039;Requestor&#039;,&lt;br /&gt;
                                              Email =&amp;gt; &#039;noreply@example.com&#039; );&lt;br /&gt;
 $self-&amp;gt;TicketObj-&amp;gt;SquelchMailTo(&#039;noreply@example.com&#039;);&lt;br /&gt;
 return 1;&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=WriteCustomAction&amp;diff=26295</id>
		<title>WriteCustomAction</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=WriteCustomAction&amp;diff=26295"/>
		<updated>2016-07-21T10:21:46Z</updated>

		<summary type="html">&lt;p&gt;Bduye: /* From &amp;quot;User Defined&amp;quot; to a module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This text in Portuguese in [[WriteCustomActionBR]]&lt;br /&gt;
&lt;br /&gt;
How to write custom action code&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Included in RT3 is the ability to create your own custom ticket actions via the Web UI. The RT3 Custom Scrip capability lets you access the RT API and is a very powerful tool for customising RT.&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
[[File:Example1ScripUI.png|thumb|left|325px|Modify a scrip UI]]Let&#039;s start with Web UI. Goto Configuration -&amp;amp;gt; Globals -&amp;amp;gt; Scrips -&amp;amp;gt; New Scrip.&lt;br /&gt;
&lt;br /&gt;
The Scrip UI will display the following selectors: Description, Condition, Action, Template and Stage. In the action selector you can pick actions based on files (modules). An outstanding action from this list is &amp;quot;User Defined&amp;quot;. The rest of this document describes this action. So in the Action field, select &amp;quot;User Defined&amp;quot; from the menu.&lt;br /&gt;
&lt;br /&gt;
Once you have selected &amp;quot;User Defined&amp;quot; from the Action Field, the following two Action code areas are enabled and used by RT:&lt;br /&gt;
* Custom action preparation code&lt;br /&gt;
* Custom action cleanup code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When a [[Transaction]] is created, RT does the following steps to enable all this magic and give you a chance to be a small God:&lt;br /&gt;
&lt;br /&gt;
* Select [[Scrip|Scrips]]&lt;br /&gt;
* Check applicability of scrips by executing [[Condition]]s&lt;br /&gt;
* Execute preparation code scrip by scrip&lt;br /&gt;
* Scrips that fail will be thrown away&lt;br /&gt;
* Execute commit code of survived scrips proceeding scrip by scrip&lt;br /&gt;
&lt;br /&gt;
When RT executes your perl Action code within this scrip, your code can become an actor upon the ticket. RT has already defined the variable $self. This variable represents an instance of class [=RT::Action::[[UserDefined]]], a subclass of &amp;lt;code&amp;gt;RT::Action::Generic&amp;lt;/code&amp;gt;. You can get more info from perldoc and from the source code.&lt;br /&gt;
&lt;br /&gt;
Instance &amp;lt;code&amp;gt;$self&amp;lt;/code&amp;gt; provides your Action code with very useful methods:&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TransactionObj&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;RT::Transaction&amp;lt;/code&amp;gt; instance, the transaction that has been created and caused all this.&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;RT::Ticket&amp;lt;/code&amp;gt; instance which represents the ticket. Our transaction was applied to it.&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TemplateObj&lt;br /&gt;
&lt;br /&gt;
Returns the template (&amp;lt;code&amp;gt;RT::Template&amp;lt;/code&amp;gt;) which was selected for this scrip.&lt;br /&gt;
&lt;br /&gt;
=== Getting more info about these objects ===&lt;br /&gt;
&lt;br /&gt;
You can get complete information about these objects from their POD (embedded documentation).&lt;br /&gt;
&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Ticket.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Ticket_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Tickets.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Tickets_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transaction.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transactions.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transactions_Overlay.pm&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
== Simple example ==&lt;br /&gt;
&lt;br /&gt;
Ok, let&#039;s try to change something.&lt;br /&gt;
&lt;br /&gt;
Requirement: There is a support queue for special customers where each request must have high priority on ticket creation.&lt;br /&gt;
&lt;br /&gt;
[[File:Example1ScripBehavior.png|thumb|275px]]Preparation code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
     # we don&#039;t need any preparation yet.&lt;br /&gt;
     return 1;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commit code:&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( 100 );&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
I hope that this example is understandable enough, but it has at least one weakness. I&#039;ve hardcoded the priority value. Since RT lets the administrator define default final priority per queue, our code should reflect that.&lt;br /&gt;
&lt;br /&gt;
 my $qfp = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;FinalPriority || 100;&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( int( $qfp * 0.9 ) );&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
This change to the logic first retrieves the [[FinalPriority]] of the current Queue or 100 if no [[FinalPriority]] is set for the Queue. Then it sets the Priority of this ticket to 90% of the retrieved Priority. The final 10% of the priority is reserved for very exclusive, super high priority requests.&lt;br /&gt;
&lt;br /&gt;
== Errors handling ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to check errors to protect you from headache. Most methods in RT that change something return a tuple ($status, $msg). If $status is not true value then something failed and $msg is error text describing the reason. Let&#039;s extend our code:&lt;br /&gt;
&lt;br /&gt;
 my $qfp = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;FinalPriority || 100;&lt;br /&gt;
 my ($status, $msg) = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( int( $qfp * 0.9 ) );&lt;br /&gt;
 unless ( $status ) {&lt;br /&gt;
     $RT::Logger-&amp;amp;gt;error(&amp;quot;Couldn&#039;t change priority: $msg&amp;quot;);&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
== What you can (not) do with scrips ==&lt;br /&gt;
&lt;br /&gt;
You can manipulate almost any object in RT within a scrip.&lt;br /&gt;
&lt;br /&gt;
* update properties of tickets, for example set properties of tickets with commands in email&lt;br /&gt;
* change linked tickets, for example [[OpenTicketOnAllMemberResolve]] and [[OpenDependantsOnResolve]]&lt;br /&gt;
* extract info from messages, implement own workflow, create approvals and many-many more actions&lt;br /&gt;
&lt;br /&gt;
Let&#039;s talk about impossible things you don&#039;t even want to try to do with a scrip:&lt;br /&gt;
&lt;br /&gt;
* you couldn&#039;t deny action scrip&#039;s triggered, for example you don&#039;t want to allow users to open ticket unless it has owner, you may think that you can create scrip &amp;quot;on ticket open block action if ticket has no owner&amp;quot;, but it&#039;s impossible. I said impossible? no... sure you can create such scrip, but instead of preventing action you can revert it by setting status back to old value. yeah, this works but don&#039;t forget that it would be two transactions &#039;set open status&#039; and &#039;set previouse status&#039;. Each action could be applied to other scrips, so really it&#039;s not preventing action.&lt;br /&gt;
* you couldn&#039;t run scrip at some time, remember RT runs scrips after creating transactions, but of course we have solution for this situation - rt-crontool.&lt;br /&gt;
&lt;br /&gt;
== How to be silent ==&lt;br /&gt;
&lt;br /&gt;
Now you put SetXxxx calls all over the places in RT and suddenly note that strange transactions appear in tickets. They have creator [[RT System|RT_System]] and describe what you&#039;ve done with your scrips. Sometimes it&#039;s better to be silent and not mislead users. These transactions also go through the steps described earlier and could trigger some conditions too. Just use the long form of SetXxx functions:&lt;br /&gt;
&lt;br /&gt;
 $TicketObj-&amp;amp;gt;_Set(Field =&amp;amp;gt; &#039;Priority&#039;, Value =&amp;amp;gt; 90, RecordTransaction =&amp;amp;gt; 0);&lt;br /&gt;
&lt;br /&gt;
The zero in the [[RecordTransaction]] argument informs RT not to record the change as a new transaction.&lt;br /&gt;
&lt;br /&gt;
== How to change ticket custom field values ==&lt;br /&gt;
&lt;br /&gt;
Step 1, get the custom field (CF) object or ID. Don&#039;t use the hardcoded CF ID from the database. [why?] Step 2, get the CF object by ticket object by ticket object (I hope you remember how to get a ticket object) and CF name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
      my $CFName = &#039;MyCustomField&#039;;&lt;br /&gt;
      my $CF = RT::CustomField-&amp;amp;gt;new( $RT::SystemUser );&lt;br /&gt;
      $CF-&amp;amp;gt;LoadByNameAndQueue( Name =&amp;amp;gt; $CFName, Queue =&amp;amp;gt; $Ticket-&amp;amp;gt;Queue );&lt;br /&gt;
      # RT has bug/feature until 3.0.10, you should load global CF yourself&lt;br /&gt;
      unless( $CF-&amp;amp;gt;id ) {&lt;br /&gt;
        # queue 0 is special case and is a synonym for global queue&lt;br /&gt;
        $CF-&amp;amp;gt;LoadByNameAndQueue( Name =&amp;amp;gt; $CFName, Queue =&amp;amp;gt; &#039;0&#039; );&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      unless( $CF-&amp;amp;gt;id ) {&lt;br /&gt;
        $RT::Logger-&amp;amp;gt;error( &amp;quot;No field $CFName in queue &amp;quot;. $Ticket-&amp;amp;gt;QueueObj-&amp;amp;gt;Name );&lt;br /&gt;
        return undef;&lt;br /&gt;
      }&lt;br /&gt;
      ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we could add value to ticket:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $Value = &#039;MyValue&#039;;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; $CF, Value =&amp;amp;gt; $Value );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; $CF, Value =&amp;amp;gt; $Value, RecordTransaction =&amp;amp;gt; 0 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you also could use custom field id instead of object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; NN , Value =&amp;amp;gt; $Value );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step by step or &amp;quot;Tickets, transactions and attachments&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
Lets look what happens with RT from the beginning when a user clicks on create button in their browser. Web server gets request with queue id, ticket subject and body, owner and etc. RT fetches info from the request that is needed for Ticket record: its Queue id, Status, Subject, [[CurrentUser]](Creator), and then runs the next code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     # init empty instance of RT::Ticket class&lt;br /&gt;
     my $TicketObj = RT::Ticket-&amp;amp;gt;new( $session{&#039;CurrentUser&#039;} );&lt;br /&gt;
     &lt;br /&gt;
     # create new record&lt;br /&gt;
     # if you more familiar with SQL then it&#039;s INSERT&lt;br /&gt;
     # this call is inherited from SearchBuilder API&lt;br /&gt;
     my $id = $TicketObj-&amp;amp;gt;Create( %ARGS );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ticket is created and it&#039;s time to record transaction into table. RT has all info for this: ticket&#039;s id that was recently created and transaction type - &#039;Create&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     # this call creates new transaction record&lt;br /&gt;
     # this is very similar to situation with new ticket record&lt;br /&gt;
     my $TransactionObj = $Ticket-&amp;amp;gt;_RecordTransaction( %ARGS );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Transactions in RT has an many-to-one mapping with ticket. One ticket =&amp;amp;gt; one or more transactions. You can get collection of transactions by calling Transactions method on a ticket object:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $transactions = $TicketObj-&amp;amp;gt;Transactions;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Each transaction belongs to only one ticket and you get ticket object with the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $ticket = $TransactionObj-&amp;amp;gt;TicketObj;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see RT still didn&#039;t use content that you wrote in the body. Content is an RT::Attachment object. You know how RT creates new record and know about Ticket-Transaction relation, the same relationship applies to Attachments and Transactions.&lt;br /&gt;
&lt;br /&gt;
== From &amp;quot;User Defined&amp;quot; to a module ==&lt;br /&gt;
&lt;br /&gt;
User defined actions you write in the web UI are handy and quick way to write an action. However, at some point you want to re-use your action, make it configurable, edit it in more suitable editor rather than text area, make it more complex and consist of additional methods. So it&#039;s time to move from &amp;quot;User Defined&amp;quot; action to your first module file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 use strict;&lt;br /&gt;
 use warnings;&lt;br /&gt;
 &lt;br /&gt;
 package RT::Action::MyAction;&lt;br /&gt;
 use base qw(RT::Action::Generic);&lt;br /&gt;
 &lt;br /&gt;
 sub Prepare {&lt;br /&gt;
   my $self = shift;&lt;br /&gt;
 &lt;br /&gt;
   ... here goes preparation code ...&lt;br /&gt;
 &lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 sub Commit {&lt;br /&gt;
   my $self = shift;&lt;br /&gt;
 &lt;br /&gt;
   ... here goes commit code ...&lt;br /&gt;
 &lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: for RT4, replace &#039;&#039;&#039;RT::Action::Generic&#039;&#039;&#039; by &#039;&#039;&#039;RT::Action&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
That&#039;s it. Save it as &#039;&#039;&#039;lib/RT/Action/MyAction.pm&#039;&#039;&#039; (it is important that the file have the same name as the package (&amp;quot;MyAction&amp;quot; in the example)), fill in preparation and commit code then you can register your action in the DB. Use the following data file and [[AddDatabaseRecords]] instructions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 @ScripActions = (&lt;br /&gt;
   {&lt;br /&gt;
     Name        =&amp;amp;gt; &#039;My super duper action&#039;,&lt;br /&gt;
     Description =&amp;amp;gt; &#039;Super-puper action that does hell of a job&#039; ,&lt;br /&gt;
     ExecModule =&amp;amp;gt; &#039;MyAction&#039;,&lt;br /&gt;
     Argument   =&amp;amp;gt; &#039;some argument if needed&#039;&lt;br /&gt;
   },&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your action in the DB and you can pick it for a scrip through the Web UI instead of picking &amp;quot;User Defined&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
Other documentation on this wiki that may help&lt;br /&gt;
&lt;br /&gt;
[[GlobalObjects]], [[ObjectModel]]&lt;br /&gt;
&lt;br /&gt;
== Special thanks ==&lt;br /&gt;
&lt;br /&gt;
* [[TimWilson]], who was the main editor and reviewer&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=InitialData&amp;diff=26294</id>
		<title>InitialData</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=InitialData&amp;diff=26294"/>
		<updated>2016-07-20T21:53:23Z</updated>

		<summary type="html">&lt;p&gt;Bduye: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding new records into RT&#039;s database =&lt;br /&gt;
&lt;br /&gt;
This might be helpful if you want to add a record in the RT DB and don&#039;t want to mess things by SQL INSERT queries and don&#039;t want to write code.&lt;br /&gt;
&lt;br /&gt;
This is especially helpful when you write custom scrip actions/conditions as module files instead of using &amp;lt;code&amp;gt;User Defined&amp;lt;/code&amp;gt; and want to register them in the DB.&lt;br /&gt;
&lt;br /&gt;
= rt-setup-database and initialdata =&lt;br /&gt;
&lt;br /&gt;
RT comes with &amp;lt;code&amp;gt;etc/initialdata&amp;lt;/code&amp;gt; file that is parsed and inserted into newly created DB when you install for the first time. When you upgrade RT, database changes comes in similar file.&lt;br /&gt;
&lt;br /&gt;
Basic idea is that you can write such files and use &amp;lt;code&amp;gt;sbin/rt-setup-database&amp;lt;/code&amp;gt; script to insert the data:&lt;br /&gt;
&lt;br /&gt;
 /path/to/rt3/sbin/rt-setup-database --action insert --datafile /path/to/data-file&lt;br /&gt;
&lt;br /&gt;
= Example =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 @ScripConditions = (&lt;br /&gt;
    { Name           =&amp;amp;gt; &#039;On Some Event&#039;,&lt;br /&gt;
      Description   =&amp;amp;gt; &#039;When some event happens&#039;,&lt;br /&gt;
      ExecModule  =&amp;amp;gt; &#039;SomeEvent&#039;,&lt;br /&gt;
      Argument     =&amp;amp;gt; &#039;some argument&#039;,&lt;br /&gt;
      ApplicableTransTypes =&amp;amp;gt; &#039;Any&#039;&lt;br /&gt;
    },&lt;br /&gt;
  );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= How it works =&lt;br /&gt;
&lt;br /&gt;
File should be a valid perl scrip that fill a bunch of arrays with data that should be inserted, for example: @Queues, @Scrips, @Groups and so on. Full list of available arrays you can find in method InsertData that is in &amp;lt;code&amp;gt;lib/RT/Handle.pm&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
You put hashes with key/value pairs into these arrays. So it looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 @SomeArray = (&lt;br /&gt;
   {&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   {&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   ...&lt;br /&gt;
 );&lt;br /&gt;
 @AnotherArray = (&lt;br /&gt;
   {&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   ...&lt;br /&gt;
 );&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually you don&#039;t write any code, but this doesn&#039;t mean you can not. Sometimes you do want to write a bit of code, for example to load a bunch of data from a text file.&lt;br /&gt;
&lt;br /&gt;
= Where to find more info =&lt;br /&gt;
&lt;br /&gt;
There is no much to document about it and there are plenty of examples in RT itself. Start from &amp;lt;code&amp;gt;etc/initialdata&amp;lt;/code&amp;gt; then look at &amp;lt;code&amp;gt;etc/upgrade/*/content&amp;lt;/code&amp;gt; files, then look at the same set in [[RTIR]] extension or any other extension.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
[[WriteCustomAction]] and [[WriteCustomCondition]] for details on @ScripActions and @ScripConditions&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=InitialData&amp;diff=26293</id>
		<title>InitialData</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=InitialData&amp;diff=26293"/>
		<updated>2016-07-20T21:53:06Z</updated>

		<summary type="html">&lt;p&gt;Bduye: add &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt; blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding new records into RT&#039;s database =&lt;br /&gt;
&lt;br /&gt;
This might be helpful if you want to add a record in the RT DB and don&#039;t want to mess things by SQL INSERT queries and don&#039;t want to write code.&lt;br /&gt;
&lt;br /&gt;
This is especially helpful when you write custom scrip actions/conditions as module files instead of using &amp;lt;code&amp;gt;User Defined&amp;lt;/code&amp;gt; and want to register them in the DB.&lt;br /&gt;
&lt;br /&gt;
= rt-setup-database and initialdata =&lt;br /&gt;
&lt;br /&gt;
RT comes with &amp;lt;code&amp;gt;etc/initialdata&amp;lt;/code&amp;gt; file that is parsed and inserted into newly created DB when you install for the first time. When you upgrade RT, database changes comes in similar file.&lt;br /&gt;
&lt;br /&gt;
Basic idea is that you can write such files and use &amp;lt;code&amp;gt;sbin/rt-setup-database&amp;lt;/code&amp;gt; script to insert the data:&lt;br /&gt;
&lt;br /&gt;
 /path/to/rt3/sbin/rt-setup-database --action insert --datafile /path/to/data-file&lt;br /&gt;
&lt;br /&gt;
= Example =&lt;br /&gt;
&lt;br /&gt;
 @ScripConditions = (&lt;br /&gt;
    { Name           =&amp;amp;gt; &#039;On Some Event&#039;,&lt;br /&gt;
      Description   =&amp;amp;gt; &#039;When some event happens&#039;,&lt;br /&gt;
      ExecModule  =&amp;amp;gt; &#039;SomeEvent&#039;,&lt;br /&gt;
      Argument     =&amp;amp;gt; &#039;some argument&#039;,&lt;br /&gt;
      ApplicableTransTypes =&amp;amp;gt; &#039;Any&#039;&lt;br /&gt;
    },&lt;br /&gt;
  );&lt;br /&gt;
&lt;br /&gt;
= How it works =&lt;br /&gt;
&lt;br /&gt;
File should be a valid perl scrip that fill a bunch of arrays with data that should be inserted, for example: @Queues, @Scrips, @Groups and so on. Full list of available arrays you can find in method InsertData that is in &amp;lt;code&amp;gt;lib/RT/Handle.pm&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
You put hashes with key/value pairs into these arrays. So it looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 @SomeArray = (&lt;br /&gt;
   {&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   {&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      key =&amp;amp;gt; &#039;value&#039;,&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   ...&lt;br /&gt;
 );&lt;br /&gt;
 @AnotherArray = (&lt;br /&gt;
   {&lt;br /&gt;
      ...&lt;br /&gt;
   },&lt;br /&gt;
   ...&lt;br /&gt;
 );&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usually you don&#039;t write any code, but this doesn&#039;t mean you can not. Sometimes you do want to write a bit of code, for example to load a bunch of data from a text file.&lt;br /&gt;
&lt;br /&gt;
= Where to find more info =&lt;br /&gt;
&lt;br /&gt;
There is no much to document about it and there are plenty of examples in RT itself. Start from &amp;lt;code&amp;gt;etc/initialdata&amp;lt;/code&amp;gt; then look at &amp;lt;code&amp;gt;etc/upgrade/*/content&amp;lt;/code&amp;gt; files, then look at the same set in [[RTIR]] extension or any other extension.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
[[WriteCustomAction]] and [[WriteCustomCondition]] for details on @ScripActions and @ScripConditions&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=WriteCustomAction&amp;diff=26292</id>
		<title>WriteCustomAction</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=WriteCustomAction&amp;diff=26292"/>
		<updated>2016-07-20T21:51:09Z</updated>

		<summary type="html">&lt;p&gt;Bduye: add &amp;lt;pre&amp;gt; &amp;lt;/pre&amp;gt; blocks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This text in Portuguese in [[WriteCustomActionBR]]&lt;br /&gt;
&lt;br /&gt;
How to write custom action code&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Included in RT3 is the ability to create your own custom ticket actions via the Web UI. The RT3 Custom Scrip capability lets you access the RT API and is a very powerful tool for customising RT.&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
[[File:Example1ScripUI.png|thumb|left|325px|Modify a scrip UI]]Let&#039;s start with Web UI. Goto Configuration -&amp;amp;gt; Globals -&amp;amp;gt; Scrips -&amp;amp;gt; New Scrip.&lt;br /&gt;
&lt;br /&gt;
The Scrip UI will display the following selectors: Description, Condition, Action, Template and Stage. In the action selector you can pick actions based on files (modules). An outstanding action from this list is &amp;quot;User Defined&amp;quot;. The rest of this document describes this action. So in the Action field, select &amp;quot;User Defined&amp;quot; from the menu.&lt;br /&gt;
&lt;br /&gt;
Once you have selected &amp;quot;User Defined&amp;quot; from the Action Field, the following two Action code areas are enabled and used by RT:&lt;br /&gt;
* Custom action preparation code&lt;br /&gt;
* Custom action cleanup code&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When a [[Transaction]] is created, RT does the following steps to enable all this magic and give you a chance to be a small God:&lt;br /&gt;
&lt;br /&gt;
* Select [[Scrip|Scrips]]&lt;br /&gt;
* Check applicability of scrips by executing [[Condition]]s&lt;br /&gt;
* Execute preparation code scrip by scrip&lt;br /&gt;
* Scrips that fail will be thrown away&lt;br /&gt;
* Execute commit code of survived scrips proceeding scrip by scrip&lt;br /&gt;
&lt;br /&gt;
When RT executes your perl Action code within this scrip, your code can become an actor upon the ticket. RT has already defined the variable $self. This variable represents an instance of class [=RT::Action::[[UserDefined]]], a subclass of &amp;lt;code&amp;gt;RT::Action::Generic&amp;lt;/code&amp;gt;. You can get more info from perldoc and from the source code.&lt;br /&gt;
&lt;br /&gt;
Instance &amp;lt;code&amp;gt;$self&amp;lt;/code&amp;gt; provides your Action code with very useful methods:&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TransactionObj&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;RT::Transaction&amp;lt;/code&amp;gt; instance, the transaction that has been created and caused all this.&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;RT::Ticket&amp;lt;/code&amp;gt; instance which represents the ticket. Our transaction was applied to it.&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TemplateObj&lt;br /&gt;
&lt;br /&gt;
Returns the template (&amp;lt;code&amp;gt;RT::Template&amp;lt;/code&amp;gt;) which was selected for this scrip.&lt;br /&gt;
&lt;br /&gt;
=== Getting more info about these objects ===&lt;br /&gt;
&lt;br /&gt;
You can get complete information about these objects from their POD (embedded documentation).&lt;br /&gt;
&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Ticket.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Ticket_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Tickets.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Tickets_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transaction.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transaction_Overlay.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transactions.pm&lt;br /&gt;
 perldoc /opt/rt3/lib/RT/Transactions_Overlay.pm&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
== Simple example ==&lt;br /&gt;
&lt;br /&gt;
Ok, let&#039;s try to change something.&lt;br /&gt;
&lt;br /&gt;
Requirement: There is a support queue for special customers where each request must have high priority on ticket creation.&lt;br /&gt;
&lt;br /&gt;
[[File:Example1ScripBehavior.png|thumb|275px]]Preparation code:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
     # we don&#039;t need any preparation yet.&lt;br /&gt;
     return 1;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Commit code:&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( 100 );&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
I hope that this example is understandable enough, but it has at least one weakness. I&#039;ve hardcoded the priority value. Since RT lets the administrator define default final priority per queue, our code should reflect that.&lt;br /&gt;
&lt;br /&gt;
 my $qfp = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;FinalPriority || 100;&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( int( $qfp * 0.9 ) );&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
This change to the logic first retrieves the [[FinalPriority]] of the current Queue or 100 if no [[FinalPriority]] is set for the Queue. Then it sets the Priority of this ticket to 90% of the retrieved Priority. The final 10% of the priority is reserved for very exclusive, super high priority requests.&lt;br /&gt;
&lt;br /&gt;
== Errors handling ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to check errors to protect you from headache. Most methods in RT that change something return a tuple ($status, $msg). If $status is not true value then something failed and $msg is error text describing the reason. Let&#039;s extend our code:&lt;br /&gt;
&lt;br /&gt;
 my $qfp = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;FinalPriority || 100;&lt;br /&gt;
 my ($status, $msg) = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetPriority( int( $qfp * 0.9 ) );&lt;br /&gt;
 unless ( $status ) {&lt;br /&gt;
     $RT::Logger-&amp;amp;gt;error(&amp;quot;Couldn&#039;t change priority: $msg&amp;quot;);&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
== What you can (not) do with scrips ==&lt;br /&gt;
&lt;br /&gt;
You can manipulate almost any object in RT within a scrip.&lt;br /&gt;
&lt;br /&gt;
* update properties of tickets, for example set properties of tickets with commands in email&lt;br /&gt;
* change linked tickets, for example [[OpenTicketOnAllMemberResolve]] and [[OpenDependantsOnResolve]]&lt;br /&gt;
* extract info from messages, implement own workflow, create approvals and many-many more actions&lt;br /&gt;
&lt;br /&gt;
Let&#039;s talk about impossible things you don&#039;t even want to try to do with a scrip:&lt;br /&gt;
&lt;br /&gt;
* you couldn&#039;t deny action scrip&#039;s triggered, for example you don&#039;t want to allow users to open ticket unless it has owner, you may think that you can create scrip &amp;quot;on ticket open block action if ticket has no owner&amp;quot;, but it&#039;s impossible. I said impossible? no... sure you can create such scrip, but instead of preventing action you can revert it by setting status back to old value. yeah, this works but don&#039;t forget that it would be two transactions &#039;set open status&#039; and &#039;set previouse status&#039;. Each action could be applied to other scrips, so really it&#039;s not preventing action.&lt;br /&gt;
* you couldn&#039;t run scrip at some time, remember RT runs scrips after creating transactions, but of course we have solution for this situation - rt-crontool.&lt;br /&gt;
&lt;br /&gt;
== How to be silent ==&lt;br /&gt;
&lt;br /&gt;
Now you put SetXxxx calls all over the places in RT and suddenly note that strange transactions appear in tickets. They have creator [[RT System|RT_System]] and describe what you&#039;ve done with your scrips. Sometimes it&#039;s better to be silent and not mislead users. These transactions also go through the steps described earlier and could trigger some conditions too. Just use the long form of SetXxx functions:&lt;br /&gt;
&lt;br /&gt;
 $TicketObj-&amp;amp;gt;_Set(Field =&amp;amp;gt; &#039;Priority&#039;, Value =&amp;amp;gt; 90, RecordTransaction =&amp;amp;gt; 0);&lt;br /&gt;
&lt;br /&gt;
The zero in the [[RecordTransaction]] argument informs RT not to record the change as a new transaction.&lt;br /&gt;
&lt;br /&gt;
== How to change ticket custom field values ==&lt;br /&gt;
&lt;br /&gt;
Step 1, get the custom field (CF) object or ID. Don&#039;t use the hardcoded CF ID from the database. [why?] Step 2, get the CF object by ticket object by ticket object (I hope you remember how to get a ticket object) and CF name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      ...&lt;br /&gt;
      my $CFName = &#039;MyCustomField&#039;;&lt;br /&gt;
      my $CF = RT::CustomField-&amp;amp;gt;new( $RT::SystemUser );&lt;br /&gt;
      $CF-&amp;amp;gt;LoadByNameAndQueue( Name =&amp;amp;gt; $CFName, Queue =&amp;amp;gt; $Ticket-&amp;amp;gt;Queue );&lt;br /&gt;
      # RT has bug/feature until 3.0.10, you should load global CF yourself&lt;br /&gt;
      unless( $CF-&amp;amp;gt;id ) {&lt;br /&gt;
        # queue 0 is special case and is a synonym for global queue&lt;br /&gt;
        $CF-&amp;amp;gt;LoadByNameAndQueue( Name =&amp;amp;gt; $CFName, Queue =&amp;amp;gt; &#039;0&#039; );&lt;br /&gt;
      }&lt;br /&gt;
      &lt;br /&gt;
      unless( $CF-&amp;amp;gt;id ) {&lt;br /&gt;
        $RT::Logger-&amp;amp;gt;error( &amp;quot;No field $CFName in queue &amp;quot;. $Ticket-&amp;amp;gt;QueueObj-&amp;amp;gt;Name );&lt;br /&gt;
        return undef;&lt;br /&gt;
      }&lt;br /&gt;
      ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we could add value to ticket:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $Value = &#039;MyValue&#039;;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; $CF, Value =&amp;amp;gt; $Value );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; $CF, Value =&amp;amp;gt; $Value, RecordTransaction =&amp;amp;gt; 0 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
you also could use custom field id instead of object.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $Ticket-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; NN , Value =&amp;amp;gt; $Value );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step by step or &amp;quot;Tickets, transactions and attachments&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
Lets look what happens with RT from the beginning when a user clicks on create button in their browser. Web server gets request with queue id, ticket subject and body, owner and etc. RT fetches info from the request that is needed for Ticket record: its Queue id, Status, Subject, [[CurrentUser]](Creator), and then runs the next code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     # init empty instance of RT::Ticket class&lt;br /&gt;
     my $TicketObj = RT::Ticket-&amp;amp;gt;new( $session{&#039;CurrentUser&#039;} );&lt;br /&gt;
     &lt;br /&gt;
     # create new record&lt;br /&gt;
     # if you more familiar with SQL then it&#039;s INSERT&lt;br /&gt;
     # this call is inherited from SearchBuilder API&lt;br /&gt;
     my $id = $TicketObj-&amp;amp;gt;Create( %ARGS );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ticket is created and it&#039;s time to record transaction into table. RT has all info for this: ticket&#039;s id that was recently created and transaction type - &#039;Create&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     # this call creates new transaction record&lt;br /&gt;
     # this is very similar to situation with new ticket record&lt;br /&gt;
     my $TransactionObj = $Ticket-&amp;amp;gt;_RecordTransaction( %ARGS );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Transactions in RT has an many-to-one mapping with ticket. One ticket =&amp;amp;gt; one or more transactions. You can get collection of transactions by calling Transactions method on a ticket object:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $transactions = $TicketObj-&amp;amp;gt;Transactions;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Each transaction belongs to only one ticket and you get ticket object with the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 my $ticket = $TransactionObj-&amp;amp;gt;TicketObj;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
As you can see RT still didn&#039;t use content that you wrote in the body. Content is an RT::Attachment object. You know how RT creates new record and know about Ticket-Transaction relation, the same relationship applies to Attachments and Transactions.&lt;br /&gt;
&lt;br /&gt;
== From &amp;quot;User Defined&amp;quot; to a module ==&lt;br /&gt;
&lt;br /&gt;
User defined actions you write in the web UI are handy and quick way to write an action. However, at some point you want to re-use your action, make it configurable, edit it in more suitable editor rather than text area, make it more complex and consist of additional methods. So it&#039;s time to move from &amp;quot;User Defined&amp;quot; action to your first module file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 use strict;&lt;br /&gt;
 use warnings;&lt;br /&gt;
 &lt;br /&gt;
 package RT::Action::MyAction;&lt;br /&gt;
 use base qw(RT::Action::Generic);&lt;br /&gt;
 &lt;br /&gt;
 sub Prepare {&lt;br /&gt;
   my $self = shift;&lt;br /&gt;
 &lt;br /&gt;
   ... here goes preparation code ...&lt;br /&gt;
 &lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 sub Commit {&lt;br /&gt;
   my $self = shift;&lt;br /&gt;
 &lt;br /&gt;
   ... here goes commit code ...&lt;br /&gt;
 &lt;br /&gt;
   return 1;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That&#039;s it. Save it as &#039;&#039;&#039;lib/RT/Action/MyAction.pm&#039;&#039;&#039; (it is important that the file have the same name as the package (&amp;quot;MyAction&amp;quot; in the example)), fill in preparation and commit code then you can register your action in the DB. Use the following data file and [[AddDatabaseRecords]] instructions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 @ScripActions = (&lt;br /&gt;
   {&lt;br /&gt;
     Name        =&amp;amp;gt; &#039;My super duper action&#039;,&lt;br /&gt;
     Description =&amp;amp;gt; &#039;Super-puper action that does hell of a job&#039; ,&lt;br /&gt;
     ExecModule =&amp;amp;gt; &#039;MyAction&#039;,&lt;br /&gt;
     Argument   =&amp;amp;gt; &#039;some argument if needed&#039;&lt;br /&gt;
   },&lt;br /&gt;
 );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your action in the DB and you can pick it for a scrip through the Web UI instead of picking &amp;quot;User Defined&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
Other documentation on this wiki that may help&lt;br /&gt;
&lt;br /&gt;
[[GlobalObjects]], [[ObjectModel]]&lt;br /&gt;
&lt;br /&gt;
== Special thanks ==&lt;br /&gt;
&lt;br /&gt;
* [[TimWilson]], who was the main editor and reviewer&lt;/div&gt;</summary>
		<author><name>Bduye</name></author>
	</entry>
</feed>