[rt-users] RT3.8.7 using custom fields to restrict sending a reply on resolve

Chris Herrmann chrisherrmann7 at gmail.com
Mon Feb 27 22:32:00 EST 2012


Hi,

I'm trying to implement a system so that if a custom field is set to
"Y", then the system will send an email (specified by a template) to
the requestor. If the CF is "N" or blank then it will not send, and
will simply resolve the ticket. I've borrowed from several other
sources such as
http://lists.bestpractical.com/pipermail/rt-users/2010-April/064498.html
and http://tpokorra.blogspot.com.au/2009/01/request-tracker-scrip-that-involves.html
but my end goal is a little different.

I've tried various combinations of things that I'll describe in more
detail below, but the short version is that I cannot get it to
correctly send when CF=Y and not send when CF=N.

So far I have:

- Created a template for the email (this part works OK - it looks
correct when I test it)
- Have created a scrip as follows on a test internal queue...

Description:SendFeedbackOnResolve
Condition: On Resolve
Action: AutoReply to Requestors
Template: MyCustomTemplate
Stage: TransactionCreate

Custom Condition:
my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if  ($trans->Type eq 'CustomField')
    {my $cf = new RT::CustomField($RT::SystemUser);
     $cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "RequestFeedback");
     return 0 unless $cf->id;
     if  ($trans->Field == $cf->id &&
          $trans->NewValue eq "Y")
          {
           return 1;
          }
    }
return 0;

==============
This custom condition sends the email in every circumstance.
If I add Custom action preparation code: return 1; it does not appear
to change the behaviour
If I add Custom action cleanup code: return 1/0; it modifies the
behaviour as follows:
1 --> sends email
0 --> doesn't send email

If I move that code to the action clean code block it always sends a message.

I've also tried with TransactionBatch instead of create, and action
"NotifyRequestors" but with no success.

Help! As you may have guessed I'm not a coder, so I've instead tried
to work through permutations to see how changing things impacts the
result... unfortunately none of it as desired :/

One thing that occured to me (but I don't know how to do) is to change
the action to "User Defined" and then if the conditions are met, to
trigger an auto-reply with the desired template BUT I don't know how
to do this...

Thanks in advance,

Chris



More information about the rt-users mailing list