<div dir="ltr">If I understand correctly, you only want the scrip to apply if there's correspondence, AND the status is changed to resolved, AND a RefersTo link is added.<br><br>Each of these actions on the ticket occurs as a separate transaction, and the order in which those transactions occur is not clearly defined. Therefore, your suspicion is correct that running the scrip in transaction batch mode is required.<br>
<br>When run in batch mode, you can access a list of all of the transactions this way:<br><br><font face="courier new, monospace">my @txns = @{ $self->TicketObj->TransactionBatch };<br></font><br>You can then loop over each transaction looking for the required traits. This untested code should be close to what you need:<br>
<br><font face="courier new, monospace">my ($found_correspondence, $found_resolved, $found_refersto);</font><div><font face="courier new, monospace">my @txns = @{ $self->TicketObj->TransactionBatch };<br></font><div>
<span style="font-family:'courier new',monospace">for my $txn (@txns) {</span><br></div><div><font face="courier new, monospace"><br></font><div><font face="courier new, monospace"> # look for correspondence<br>
if ($txn->Type eq 'Correspond') {</font></div><div><font face="courier new, monospace"> RT::Logger->debug('this operation involves correspondence');<br> $found_correspondence++;<br>
next;<br>
}<br><br></font></div><div><font face="courier new, monospace"> # look for status change to resolved</font><div><font face="courier new, monospace"> if (</font></div><div><font face="courier new, monospace"> (</font></div>
<div><font face="courier new, monospace"> $txn->Type eq 'Status'</font></div><div><font face="courier new, monospace"> or ($txn->Type eq 'Set' and $txn->Field eq 'Status')</font></div>
<div><font face="courier new, monospace"> )</font></div><div><font face="courier new, monospace"> and $txn->NewValue eq 'resolved'</font></div>
<div><font face="courier new, monospace"> ) {</font></div><span style="font-family:'courier new',monospace"> RT::Logger->debug('this operation involves resolution');</span><br style="font-family:'courier new',monospace">
<font face="courier new, monospace"> $found_resolved++;<br> next;<br></font><div><font face="courier new, monospace"> }<br></font><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"> # look for addition of RefersTo link</font></div>
<div><font face="courier new, monospace"> if ($txn->Type eq 'AddLink' and $txn->Field eq 'RefersTo') {</font></div><span style="font-family:'courier new',monospace"> RT::Logger->debug('this operation involves adding a RefersTo link');</span><br style="font-family:'courier new',monospace">
<div><font face="courier new, monospace"> $found_refersto++;</font></div><div><font face="courier new, monospace"> next;</font></div><div><font face="courier new, monospace"> }</font></div><div><font face="courier new, monospace"><br>
</font></div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">return 0 if not $found_correspondence;</font></div><div><font face="courier new, monospace">return 0 if not $found_resolved;</font></div>
<div><font face="courier new, monospace">return 0 if not $found_refersto;</font></div><div><font face="courier new, monospace">return 1;</font></div><div><br></div><div><br><div>
<div class="gmail_quote">On 03/08/2014 10:51 am, "Foggi, Nicola" <<a href="mailto:NFOGGI@depaul.edu" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=NFOGGI@depaul.edu&cc=&bcc=&su=&body=','_blank');return false;">NFOGGI@depaul.edu</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Version : RT-4.0.19<br>
<br>
Hey All,<br>
<br>
Running into a slight problem with a new queue I'm attempting to roll out a new queue that uses some "pre-canned" template responses using Articles from the integrated RTFM system in 4.0.19 now. I've changed the lifecycle to make the open -> resolve a default RESPOND vs COMMENT and that's working. However, I want to send a default template response if the admin forgets to choose an article to respond with. I came up with the following code below for the custom codition. I'm detecting if the ticket has a ReferTo set and then if it doesn't return code 1 to that the scrip executes which sends the template, otherwise, sets it to 0 so it skips the scrip.<br>
<br>
The problem I'm running into is it appears the run the scrip prior to linking the article to ticket, so it always thinks the admin hasn't attached an article when they actually have. Is there anything I can do to execute the scrip post process of attaching the article (I tried setting it to Transaction Batch).<br>
<br>
Any ideas would be greatly appreciated.<br>
<br>
Thanks<br>
<br>
Nicola<br>
<br>
[custom condition below]<br>
<br>
my $RefersToTickets = $self->TicketObj->RefersTo;<br>
my $FirstRefersToTicketLink = $RefersToTickets->Next;<br>
<br>
my $returncode = 0;<br>
<br>
my $txn = $self->TransactionObj;#<br>
my $type = $txn->Type;<br>
return 0 unless $type eq "Status"<br>
|| ( $type eq 'Set' && $txn->Field eq 'Status');<br>
<br>
if ($txn->NewValue eq "resolved") {<br>
<br>
eval {$FirstRefersToTicketLink->TargetURI->URI};<br>
my $results = $@;<br>
$RT::Logger->info('219 - ' . $results);<br>
if ($results =~ qr{^Can't call method}) {<br>
$RT::Logger->info('UNDEFINED');<br>
$returncode = 1;<br>
} else {<br>
$returncode = 0;<br>
};<br>
<br>
};<br>
<br>
$RT::Logger->info('Return Code: ' . $returncode);<br>
return $returncode;<br>
--<br>
RT Training - Boston, September 9-10<br>
<a href="http://bestpractical.com/training" target="_blank">http://bestpractical.com/training</a><br>
</blockquote></div>
</div></div></div></div></div></div>