<html>
<body>
Hi Mark (and Askar),<br><br>
After reviewing my previous advice, I've changed my mind.  This
should be a cleaner solution.<br><br>
1.  Don't mess with your templates.<br><br>
2.  I don't know whether _Set works with custom fields, so I'd use
the following to set your CF in the scrip I sent you.  The scrip
should probably be a queue scrip, not global, unless you want to do this
for all your queues:<br>
set_custom('noemail', "yes", 0);<br>
### Sets custom field value<br>
### Usage: set_custom($field_name, $field_value,
$record_transaction)<br>
sub set_custom {<br>
  my ($CFName, $CFValue, $record) = @_;<br>
  $record = $record ? 1 : 0;<br>
  my $cf = RT::CustomField->new($RT::SystemUser);<br>
  my ($id,$msg) = $cf->LoadByName(Name=>$CFName,);<br>
  if (!$id) {<br>
    $RT::Logger->debug("Error loading custom field
'$CFName'");<br>
    return undef;<br>
  }<br>
  ($id, $msg) = $Ticket->AddCustomFieldValue<br>
     (Field=>$cf, Value=>$CFValue,
RecordTransaction=>$record);<br>
}<br><br>
3.  Modify your Global Scrips #6 ("<font size=2>On Correspond
Notify Requestors and Ccs with template Correspondence</font>") and
#7 ("<font size=2>On Correspond Notify Other Recipients with
template Correspondence</font>") and<br>
  a) change the Condition to User Defined; and<br>
  b) put the following code in the Custom condition area of both
scrips:<br>
{ ### True when transaction is incoming email and CF 'noemail' is not
set<br>
  my $Transaction = $self->TransactionObj;<br>
  my $Ticket = $self->TicketObj;<br>
  my $val = $Transaction->Type eq "Correspond"<br>
      && !
get_custom("noemail");<br>
  return $val;<br><br>
  ### Returns custom field value<br>
  ### get_custom($field_name)<br>
  sub get_custom {<br>
    my $target_name = $_[0];<br>
    my $val =
$Ticket->FirstCustomFieldValue($target_name);<br>
    return $val if defined $val;<br>
    return undef;<br>
  }<br>
}<br><br>
So you should have 2 scenarios now with incoming email.<br>
1.  Email is from AdminCc and contains trigger word(s) in first
line.<br>
  a) Your new scrip fires and sets the CF 'noemail' to 'yes', Owner
to email sender, Status to resolved<br>
  b) Global scrip #5 ("<font size=2>On Correspond Notify
AdminCcs with template Admin Correspondence</font>") fires and sends
mail to AdminCcs<br>
  c) Global scrips #6 and #7 do not fire because CF 'noemail' is
set, so no mail is sent to anyone else<br><br>
2.  Email is not from AdminCc or does not contain trigger word(s) in
first line:<br>
  a) Your new scrip does not fire because both conditions are not
met, so CF 'noemail' is not set<br>
  b) Global scrip #5 fires<br>
  c) Global scrips #6 and #7 fire because CF 'noemail' either
doesn't exist or is not set<br><br>
Have fun!<br><br>
Regards,<br>
Gene<br><br>
At 10:06 AM 11/27/2007, Mark Fuller wrote:<br>
<blockquote type=cite class=cite cite="">Ok I am very new to this so I
added<br><br>
<br>
 $Ticket->_Set(Field => 'noemail', Value => 'yes',
RecordTransaction => 0);<br><br>
Now how do I tell the correspondence to look for that. And also if I
change<br>
the main script like that and I have the custom field set how do I get
the<br>
filed to be blank or no so that all future correspondence will work.
<br><br>
Again I am new to RT but we love it and are expanding it's use. I
thought<br>
about command by email but the CTO is concerned as am I with security
and<br>
this seems the safer way. Also we do want to comment via email<br><br>
Mark Fuller<br><br>
BandTel Engineering<br><br>
603-528-6538 Option 2<br><br>
603-528-6937 FAX<br><br>
-----Original Message-----<br>
From: Gene LeDuc
[<a href="mailto:gleduc@mail.sdsu.edu" eudora="autourl">
mailto:gleduc@mail.sdsu.edu</a>] <br>
Sent: Monday, November 26, 2007 4:27 PM<br>
To: Mark Fuller<br>
Cc: rt-users@lists.bestpractical.com<br>
Subject: RE: [rt-users] take and resolve actions via email<br><br>
Hi Mark,<br><br>
I'm not sure how you could change a correspondence transaction to a <br>
comment.  However...<br><br>
If I wanted to just change the way that email is sent (only AdminCcs
<br>
getting an email), I'd add a custom field to the queue called <br>
"NoCorrespond" and then modify the Correspondence template used
for the "On <br>
Correspond" scrip to include a check at the beginning to see if
there is a <br>
"NoCorrespond" field and whether it has anything in it. 
If so, exit the <br>
template and don't send the email, otherwise proceed as usual.  Then
I'd <br>
have the scrip I gave you put something into the "NoCorrespond"
custom <br>
field at the same time that it sets the owner and status.  It's kind
of <br>
clunky and there are probably more elegant solutions, but I think it
would <br>
work.  You might also want to make another scrip to send the mail to
the <br>
AdminCc when the "NoCorrespond" field gets something assigned
to it (by <br>
your other scrip), something like (I haven't tried this scrip, so it may
<br>
need work):<br><br>
Condition: User Defined<br>
Action: Notify AdminCcs as Comment<br>
Template: Global template: Admin Comment<br>
Custom condtion:<br>
{ ### True on state change to "NoCorrespond"<br>
   my $Transaction = $self->TransactionObj;<br>
   my $val = $Transaction->Type eq
"CustomField"<br>
       && $Transaction->Field eq
"NoCorrespond"<br>
       ;<br>
   return $val;<br>
}<br><br>
Good luck!<br>
Gene<br><br>
At 12:00 PM 11/26/2007, Mark Fuller wrote:<br>
>Thanks Gene it works great but.. Is there a way to make it a comment
so <br>
>only admin staff gets it<br>
><br>
>Mark Fuller<br>
><br>
>-----Original Message-----<br>
>From: Gene LeDuc
[<a href="mailto:gleduc@mail.sdsu.edu" eudora="autourl">
mailto:gleduc@mail.sdsu.edu</a>]<br>
>Sent: Monday, November 26, 2007 12:26 PM<br>
>To: Mark Fuller<br>
>Cc: rt-users@lists.bestpractical.com<br>
>Subject: RE: [rt-users] take and resolve actions via email<br>
><br>
><br>
>Hi Mark,<br>
><br>
>Here's the scrip we use to resolve tickets via e-mail.<br>
><br>
>In order to resolve a ticket this way, the e-mail must be from an
<br>
>AdminCc for that queue and it must contain the word "Ok" on
the first <br>
>line.<br>
><br>
>Description: Resolved by e-mail<br>
>Condition: User Defined<br>
>Action: User Defined<br>
>Template: Global template: Blank<br>
>Stage: TransactionCreate<br>
><br>
>Custom condition:<br>
>{ ### True if e-mail contains 'ok' - sets owner, resolves ticket<br>
>    my $Transaction = $self->TransactionObj;<br>
>    my $CreatorId =
$Transaction->CreatorObj->Id;<br>
>    my $Queue = $self->TicketObj->QueueObj;<br>
>    my $val = $Transaction->Type eq
'Correspond'<br>
>          
&& $Queue->IsAdminCc($CreatorId)<br>
>          
&& $Transaction->Content  =~ /\bok\s/i;<br>
>    return $val;<br>
>}<br>
><br>
>Custom action prep code:<br>
>return 1;<br>
><br>
>Custom action cleanup code:<br>
>### Set Set owner to e-mail sender, status to 'resolved'<br>
>my $Ticket = $self->TicketObj;<br>
>my $Transaction = $self->TransactionObj;<br>
>my $CreatorId = $Transaction->CreatorObj->Id; <br>
>$Ticket->_Set(Field=>'Owner', Value=>$CreatorId,
RecordTransaction=>0); <br>
>$Ticket->_Set(Field => 'Status', Value => 'resolved',
RecordTransaction <br>
>=> 0);<br>
><br>
>The 2 lines at the end of the cleanup code could also be:<br>
>      $Ticket->SetOwner($CreatorId);<br>
>     
$Ticket->SetStatus('resolved');<br>
>but I use _Set instead because I don't want to fire off any more
<br>
>transactions when I resolve tickets this way.<br>
><br>
>Regards,<br>
>Gene</blockquote>
<x-sigsep><p></x-sigsep>
<br>
-- <br>
Gene LeDuc, GSEC<br>
Security Analyst<br>
San Diego State University</body>
</html>