https://rt-wiki.bestpractical.com/api.php?action=feedcontributions&user=Anwe&feedformat=atomRequest Tracker Wiki - User contributions [en]2024-03-29T06:22:32ZUser contributionsMediaWiki 1.37.2https://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&diff=26307WriteCustomCondition2016-07-25T12:54:48Z<p>Anwe: /* Basic */</p>
<hr />
<div>[[Documentation]] &gt; [[WriteCustomCondition]]<br />
<br />
= How to write custom condition code =<br />
<br />
== Introduction ==<br />
<br />
[[Scrip]]s' 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.<br />
<br />
== Basic ==<br />
<br />
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.<br />
<br />
Major objects accessors are:<br />
<pre><br />
$self-&gt;TransactionObj # returns the current transaction object<br />
$self-&gt;TicketObj # returns the current ticket object<br />
$self-&gt;TemplateObj # returns the current template object<br />
</pre><br />
<br />
== Return value ==<br />
<br />
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 <code>User Defined</code> condition when you create a new scrip condition:<br />
<br />
<pre><br />
# get ticket object<br />
my $ticket = $self-&gt;TicketObj;<br />
# don't do anything if ticket is resolved<br />
return 0 if $ticket-&gt;Status eq 'resolved';<br />
# otherwise run scrip action<br />
return 1;<br />
</pre><br />
<br />
== Transaction ==<br />
<br />
Transaction object is most used object in conditions as it describes what's happened with the ticket just a few ticks ago.<br />
<br />
Most important properties of the transaction object are <code>Type</code> and <code>Field</code>. More on [[Transaction]].<br />
<br />
== Another way to add conditions to RT ==<br />
<br />
See [[NotResolved]] for another way of adding Conditions to RT<br />
<br />
== Further readings ==<br />
<br />
[[CustomConditionSnippets]], [[WriteCustomAction]], [[ScripAction]]</div>Anwehttps://rt-wiki.bestpractical.com/index.php?title=WriteCustomCondition&diff=26306WriteCustomCondition2016-07-25T12:54:31Z<p>Anwe: /* Return value */</p>
<hr />
<div>[[Documentation]] &gt; [[WriteCustomCondition]]<br />
<br />
= How to write custom condition code =<br />
<br />
== Introduction ==<br />
<br />
[[Scrip]]s' 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.<br />
<br />
== Basic ==<br />
<br />
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.<br />
<br />
Major objects accessors are:<br />
<br />
$self-&gt;TransactionObj # returns the current transaction object<br />
$self-&gt;TicketObj # returns the current ticket object<br />
$self-&gt;TemplateObj # returns the current template object<br />
<br />
== Return value ==<br />
<br />
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 <code>User Defined</code> condition when you create a new scrip condition:<br />
<br />
<pre><br />
# get ticket object<br />
my $ticket = $self-&gt;TicketObj;<br />
# don't do anything if ticket is resolved<br />
return 0 if $ticket-&gt;Status eq 'resolved';<br />
# otherwise run scrip action<br />
return 1;<br />
</pre><br />
<br />
== Transaction ==<br />
<br />
Transaction object is most used object in conditions as it describes what's happened with the ticket just a few ticks ago.<br />
<br />
Most important properties of the transaction object are <code>Type</code> and <code>Field</code>. More on [[Transaction]].<br />
<br />
== Another way to add conditions to RT ==<br />
<br />
See [[NotResolved]] for another way of adding Conditions to RT<br />
<br />
== Further readings ==<br />
<br />
[[CustomConditionSnippets]], [[WriteCustomAction]], [[ScripAction]]</div>Anwe