[rt-users] take and resolve actions via email

Mark Fuller mfuller at bandtel.com
Tue Nov 27 16:37:16 EST 2007


So to be a pain but ran into an issue after setting up and testing. 
 
>Custom condition:
>{ ### True if e-mail contains 'ok' - sets owner, resolves ticket
>    my $Transaction = $self->TransactionObj;
>    my $CreatorId = $Transaction->CreatorObj->Id;
>    my $Queue = $self->TicketObj->QueueObj;
>    my $val = $Transaction->Type eq 'Correspond'
>           && $Queue->IsAdminCc($CreatorId)
>           && $Transaction->Content  =~ /\bok\s/i;
>    return $val;
>}
 
I have a group of level 1 techs that do not have a unique logon since it is
an ever changing group of folks. is there a way that I can do this based on
the domain name of there email and set it to a specified user?
 
 
something like
 
%@foo.com = creatorid 21
 
Also I found a way at least for my setup to get it to not send emails to
requestors. We send the message to the comment address and I changed it to
be
 
 
Custom condition:
{ ### True if e-mail contains 'ok' - sets owner, resolves ticket
    my $Transaction = $self->TransactionObj;
    my $CreatorId = $Transaction->CreatorObj->Id;
    my $Queue = $self->TicketObj->QueueObj;
    my $val = $Transaction->Type eq 'Comment'
           && $Queue->IsAdminCc($CreatorId)
           && $Transaction->Content  =~ /\bok\s/i;
    return $val;
}
 
and that works perfect for my level 2 and 3 support groups
 
 

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAX

 

-----Original Message-----
From: Gene LeDuc [mailto:gleduc at mail.sdsu.edu] 
Sent: Tuesday, November 27, 2007 3:50 PM
To: Mark Fuller; Asrai khn
Cc: rt-users at lists.bestpractical.com
Subject: RE: [rt-users] take and resolve actions via email


Hi Mark (and Askar),

After reviewing my previous advice, I've changed my mind.  This should be a
cleaner solution.

1.  Don't mess with your templates.

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:
set_custom('noemail', "yes", 0);
### Sets custom field value
### Usage: set_custom($field_name, $field_value, $record_transaction)
sub set_custom {
  my ($CFName, $CFValue, $record) = @_;
  $record = $record ? 1 : 0;
  my $cf = RT::CustomField->new($RT::SystemUser);
  my ($id,$msg) = $cf->LoadByName(Name=>$CFName,);
  if (!$id) {
    $RT::Logger->debug("Error loading custom field '$CFName'");
    return undef;
  }
  ($id, $msg) = $Ticket->AddCustomFieldValue
     (Field=>$cf, Value=>$CFValue, RecordTransaction=>$record);
}

3.  Modify your Global Scrips #6 ("On Correspond Notify Requestors and Ccs
with template Correspondence") and #7 ("On Correspond Notify Other
Recipients with template Correspondence") and
  a) change the Condition to User Defined; and
  b) put the following code in the Custom condition area of both scrips:
{ ### True when transaction is incoming email and CF 'noemail' is not set
  my $Transaction = $self->TransactionObj;
  my $Ticket = $self->TicketObj;
  my $val = $Transaction->Type eq "Correspond"
      && ! get_custom("noemail");
  return $val;

  ### Returns custom field value
  ### get_custom($field_name)
  sub get_custom {
    my $target_name = $_[0];
    my $val = $Ticket->FirstCustomFieldValue($target_name);
    return $val if defined $val;
    return undef;
  }
}

So you should have 2 scenarios now with incoming email.
1.  Email is from AdminCc and contains trigger word(s) in first line.
  a) Your new scrip fires and sets the CF 'noemail' to 'yes', Owner to email
sender, Status to resolved
  b) Global scrip #5 ("On Correspond Notify AdminCcs with template Admin
Correspondence") fires and sends mail to AdminCcs
  c) Global scrips #6 and #7 do not fire because CF 'noemail' is set, so no
mail is sent to anyone else

2.  Email is not from AdminCc or does not contain trigger word(s) in first
line:
  a) Your new scrip does not fire because both conditions are not met, so CF
'noemail' is not set
  b) Global scrip #5 fires
  c) Global scrips #6 and #7 fire because CF 'noemail' either doesn't exist
or is not set

Have fun!

Regards,
Gene

At 10:06 AM 11/27/2007, Mark Fuller wrote:


Ok I am very new to this so I added


 $Ticket->_Set(Field => 'noemail', Value => 'yes', RecordTransaction => 0);

Now how do I tell the correspondence to look for that. And also if I change
the main script like that and I have the custom field set how do I get the
filed to be blank or no so that all future correspondence will work. 

Again I am new to RT but we love it and are expanding it's use. I thought
about command by email but the CTO is concerned as am I with security and
this seems the safer way. Also we do want to comment via email

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAX

-----Original Message-----
From: Gene LeDuc [  <mailto:gleduc at mail.sdsu.edu>
mailto:gleduc at mail.sdsu.edu] 
Sent: Monday, November 26, 2007 4:27 PM
To: Mark Fuller
Cc: rt-users at lists.bestpractical.com
Subject: RE: [rt-users] take and resolve actions via email

Hi Mark,

I'm not sure how you could change a correspondence transaction to a 
comment.  However...

If I wanted to just change the way that email is sent (only AdminCcs 
getting an email), I'd add a custom field to the queue called 
"NoCorrespond" and then modify the Correspondence template used for the "On 
Correspond" scrip to include a check at the beginning to see if there is a 
"NoCorrespond" field and whether it has anything in it.  If so, exit the 
template and don't send the email, otherwise proceed as usual.  Then I'd 
have the scrip I gave you put something into the "NoCorrespond" custom 
field at the same time that it sets the owner and status.  It's kind of 
clunky and there are probably more elegant solutions, but I think it would 
work.  You might also want to make another scrip to send the mail to the 
AdminCc when the "NoCorrespond" field gets something assigned to it (by 
your other scrip), something like (I haven't tried this scrip, so it may 
need work):

Condition: User Defined
Action: Notify AdminCcs as Comment
Template: Global template: Admin Comment
Custom condtion:
{ ### True on state change to "NoCorrespond"
   my $Transaction = $self->TransactionObj;
   my $val = $Transaction->Type eq "CustomField"
       && $Transaction->Field eq "NoCorrespond"
       ;
   return $val;
}

Good luck!
Gene

At 12:00 PM 11/26/2007, Mark Fuller wrote:
>Thanks Gene it works great but.. Is there a way to make it a comment so 
>only admin staff gets it
>
>Mark Fuller
>
>-----Original Message-----
>From: Gene LeDuc [  <mailto:gleduc at mail.sdsu.edu>
mailto:gleduc at mail.sdsu.edu]
>Sent: Monday, November 26, 2007 12:26 PM
>To: Mark Fuller
>Cc: rt-users at lists.bestpractical.com
>Subject: RE: [rt-users] take and resolve actions via email
>
>
>Hi Mark,
>
>Here's the scrip we use to resolve tickets via e-mail.
>
>In order to resolve a ticket this way, the e-mail must be from an 
>AdminCc for that queue and it must contain the word "Ok" on the first 
>line.
>
>Description: Resolved by e-mail
>Condition: User Defined
>Action: User Defined
>Template: Global template: Blank
>Stage: TransactionCreate
>
>Custom condition:
>{ ### True if e-mail contains 'ok' - sets owner, resolves ticket
>    my $Transaction = $self->TransactionObj;
>    my $CreatorId = $Transaction->CreatorObj->Id;
>    my $Queue = $self->TicketObj->QueueObj;
>    my $val = $Transaction->Type eq 'Correspond'
>           && $Queue->IsAdminCc($CreatorId)
>           && $Transaction->Content  =~ /\bok\s/i;
>    return $val;
>}
>
>Custom action prep code:
>return 1;
>
>Custom action cleanup code:
>### Set Set owner to e-mail sender, status to 'resolved'
>my $Ticket = $self->TicketObj;
>my $Transaction = $self->TransactionObj;
>my $CreatorId = $Transaction->CreatorObj->Id; 
>$Ticket->_Set(Field=>'Owner', Value=>$CreatorId, RecordTransaction=>0); 
>$Ticket->_Set(Field => 'Status', Value => 'resolved', RecordTransaction 
>=> 0);
>
>The 2 lines at the end of the cleanup code could also be:
>      $Ticket->SetOwner($CreatorId);
>      $Ticket->SetStatus('resolved');
>but I use _Set instead because I don't want to fire off any more 
>transactions when I resolve tickets this way.
>
>Regards,
>Gene


-- 
Gene LeDuc, GSEC
Security Analyst
San Diego State University 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20071127/237df665/attachment.htm>


More information about the rt-users mailing list