<?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=Anwe</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=Anwe"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/wiki/Special:Contributions/Anwe"/>
	<updated>2026-08-22T16:29:37Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&amp;diff=26307</id>
		<title>WriteCustomCondition</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&amp;diff=26307"/>
		<updated>2016-07-25T12:54:48Z</updated>

		<summary type="html">&lt;p&gt;Anwe: /* Basic */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation]] &amp;amp;gt; [[WriteCustomCondition]]&lt;br /&gt;
&lt;br /&gt;
= How to write custom condition code =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
[[Scrip]]s&#039; 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.&lt;br /&gt;
&lt;br /&gt;
== Basic ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Major objects accessors are:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 $self-&amp;amp;gt;TransactionObj # returns the current transaction object&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj      # returns the current ticket object&lt;br /&gt;
 $self-&amp;amp;gt;TemplateObj    # returns the current template object&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Return value ==&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;User Defined&amp;lt;/code&amp;gt; condition when you create a new scrip condition:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
 # get ticket object&lt;br /&gt;
 my $ticket = $self-&amp;amp;gt;TicketObj;&lt;br /&gt;
 # don&#039;t do anything if ticket is resolved&lt;br /&gt;
 return 0 if $ticket-&amp;amp;gt;Status eq &#039;resolved&#039;;&lt;br /&gt;
 # otherwise run scrip action&lt;br /&gt;
 return 1;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Transaction ==&lt;br /&gt;
&lt;br /&gt;
Transaction object is most used object in conditions as it describes what&#039;s happened with the ticket just a few ticks ago.&lt;br /&gt;
&lt;br /&gt;
Most important properties of the transaction object are &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt;. More on [[Transaction]].&lt;br /&gt;
&lt;br /&gt;
== Another way to add conditions to RT ==&lt;br /&gt;
&lt;br /&gt;
See [[NotResolved]] for another way of adding Conditions to RT&lt;br /&gt;
&lt;br /&gt;
== Further readings ==&lt;br /&gt;
&lt;br /&gt;
[[CustomConditionSnippets]], [[WriteCustomAction]], [[ScripAction]]&lt;/div&gt;</summary>
		<author><name>Anwe</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&amp;diff=26306</id>
		<title>WriteCustomCondition</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&amp;diff=26306"/>
		<updated>2016-07-25T12:54:31Z</updated>

		<summary type="html">&lt;p&gt;Anwe: /* Return value */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Documentation]] &amp;amp;gt; [[WriteCustomCondition]]&lt;br /&gt;
&lt;br /&gt;
= How to write custom condition code =&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
[[Scrip]]s&#039; 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.&lt;br /&gt;
&lt;br /&gt;
== Basic ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Major objects accessors are:&lt;br /&gt;
&lt;br /&gt;
 $self-&amp;amp;gt;TransactionObj # returns the current transaction object&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj      # returns the current ticket object&lt;br /&gt;
 $self-&amp;amp;gt;TemplateObj    # returns the current template object&lt;br /&gt;
&lt;br /&gt;
== Return value ==&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;code&amp;gt;User Defined&amp;lt;/code&amp;gt; condition when you create a new scrip condition:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
 # get ticket object&lt;br /&gt;
 my $ticket = $self-&amp;amp;gt;TicketObj;&lt;br /&gt;
 # don&#039;t do anything if ticket is resolved&lt;br /&gt;
 return 0 if $ticket-&amp;amp;gt;Status eq &#039;resolved&#039;;&lt;br /&gt;
 # otherwise run scrip action&lt;br /&gt;
 return 1;&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Transaction ==&lt;br /&gt;
&lt;br /&gt;
Transaction object is most used object in conditions as it describes what&#039;s happened with the ticket just a few ticks ago.&lt;br /&gt;
&lt;br /&gt;
Most important properties of the transaction object are &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Field&amp;lt;/code&amp;gt;. More on [[Transaction]].&lt;br /&gt;
&lt;br /&gt;
== Another way to add conditions to RT ==&lt;br /&gt;
&lt;br /&gt;
See [[NotResolved]] for another way of adding Conditions to RT&lt;br /&gt;
&lt;br /&gt;
== Further readings ==&lt;br /&gt;
&lt;br /&gt;
[[CustomConditionSnippets]], [[WriteCustomAction]], [[ScripAction]]&lt;/div&gt;</summary>
		<author><name>Anwe</name></author>
	</entry>
</feed>