Chris,<br><br>Ever hear the term "Timing is everything"? I think your timing is off on this. Your code is triggered by the transaction that changes the status to "resolved". Therefore, "New Value" will not be "Y".<br>
<br>In your situation, I think your Custom Field already has a value of "Y" or "N" and therefore there is no "New Value" being set for it.<br><br>What you need to do is look at the value that is already present in that Custom Field.<br>
<br>Secondly, in your scrip you have already told RT to look for a standard one, "On Resolve" and then you put user-defined custom code in the condition area. That won't work.<br><br>You need to change your Condition selection to "User-Defined", then in the Custom Condition code area you need to remove all the code you put in after your definition of $trans and $ticket.<br>
<br>Then put in conditions like:<br><br>$cf_value = $ticket->whatever code defines the custom field;<br><br>if  ($trans->Type->Status &&<br>    $trans->NewValue eq "resolved" &&<br>    $cf_value eq "Y")<br>
    {<br>     return 1;<br>    }<br><br>return 0;<br><br>You'll have to get the correct code to define the value in the ticket custom field for your condition yourself as I'm out of state and not near my computer, so I don't have the code and I need my examples cause I'm not much of a perl programmer.<br>
<br>However, this will simply specify your condition to be:<br><br>"if this current transaction is about the ticket being resolved AND<br> the value in the stated custom field is "Y",<br><br>then continue, otherwise get out.<br>
<br>I think that is what you want.<br><br>I believe the RT wiki has an example or two of this, if not, my guide does.<br><br>Hope this helps.<br><br>Kenn<br><br>Kenn<br><br><br><div class="gmail_quote">On Mon, Feb 27, 2012 at 7:32 PM, Chris Herrmann <span dir="ltr"><<a href="mailto:chrisherrmann7@gmail.com">chrisherrmann7@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to implement a system so that if a custom field is set to<br>
"Y", then the system will send an email (specified by a template) to<br>
the requestor. If the CF is "N" or blank then it will not send, and<br>
will simply resolve the ticket. I've borrowed from several other<br>
sources such as<br>
<a href="http://lists.bestpractical.com/pipermail/rt-users/2010-April/064498.html" target="_blank">http://lists.bestpractical.com/pipermail/rt-users/2010-April/064498.html</a><br>
and <a href="http://tpokorra.blogspot.com.au/2009/01/request-tracker-scrip-that-involves.html" target="_blank">http://tpokorra.blogspot.com.au/2009/01/request-tracker-scrip-that-involves.html</a><br>
but my end goal is a little different.<br>
<br>
I've tried various combinations of things that I'll describe in more<br>
detail below, but the short version is that I cannot get it to<br>
correctly send when CF=Y and not send when CF=N.<br>
<br>
So far I have:<br>
<br>
- Created a template for the email (this part works OK - it looks<br>
correct when I test it)<br>
- Have created a scrip as follows on a test internal queue...<br>
<br>
Description:SendFeedbackOnResolve<br>
Condition: On Resolve<br>
Action: AutoReply to Requestors<br>
Template: MyCustomTemplate<br>
Stage: TransactionCreate<br>
<br>
Custom Condition:<br>
my $trans = $self->TransactionObj;<br>
my $ticket = $self->TicketObj;<br>
<br>
if  ($trans->Type eq 'CustomField')<br>
    {my $cf = new RT::CustomField($RT::SystemUser);<br>
     $cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "RequestFeedback");<br>
     return 0 unless $cf->id;<br>
     if  ($trans->Field == $cf->id &&<br>
          $trans->NewValue eq "Y")<br>
          {<br>
           return 1;<br>
          }<br>
    }<br>
return 0;<br>
<br>
==============<br>
This custom condition sends the email in every circumstance.<br>
If I add Custom action preparation code: return 1; it does not appear<br>
to change the behaviour<br>
If I add Custom action cleanup code: return 1/0; it modifies the<br>
behaviour as follows:<br>
1 --> sends email<br>
0 --> doesn't send email<br>
<br>
If I move that code to the action clean code block it always sends a message.<br>
<br>
I've also tried with TransactionBatch instead of create, and action<br>
"NotifyRequestors" but with no success.<br>
<br>
Help! As you may have guessed I'm not a coder, so I've instead tried<br>
to work through permutations to see how changing things impacts the<br>
result... unfortunately none of it as desired :/<br>
<br>
One thing that occured to me (but I don't know how to do) is to change<br>
the action to "User Defined" and then if the conditions are met, to<br>
trigger an auto-reply with the desired template BUT I don't know how<br>
to do this...<br>
<br>
Thanks in advance,<br>
<br>
Chris<br>
--------<br>
RT Training Sessions (<a href="http://bestpractical.com/services/training.html" target="_blank">http://bestpractical.com/services/training.html</a>)<br>
* Boston  March 5 & 6, 2012<br>
</blockquote></div><br>