Take and resolve actions via email

while reading RT3 FAQs found that …

A2: RT 3.5 has support for take and resolve actions in rt-mailgate
script, you can use them, but you should enable them in config.

Wondering what to change in RT_SiteConfig.pm and can someone give me
an examples of how to ‘take’ ‘resolve’ tickets via email, I know how
to open new tickets in specific queue using mail.

Thanks. Askar

Hi Askar,

This doesn’t answer your question about special features, but it does tell
you a way to do what you want to do.

I resolve tickets via e-mail using 3.6.3 with a fairly simple scrip. When
someone opens a ticket, I send out 2 e-mails. The first goes to the user
who opened it - they get login credentials so they can look at the
ticket. The second goes to the AdminCc list for the queue to notify them
that there’s a new ticket in the queue. If a reply comes in for that
ticket, and the sender is one of the AdminCc, and the first line of the
e-mail is “Ok”, then my scrip sets the ticket owner to the person who sent
the message and the status to resolved. Otherwise the message just gets
attached to the ticket. It would be simple to modify a scrip like that to
do a “take” as well.

If you’re interested in following this trail, let me know.

Regards,
Gene

At 06:55 AM 11/22/2007, Asrai khn wrote:

while reading RT3 FAQs found that …

A2: RT 3.5 has support for take and resolve actions in rt-mailgate
script, you can use them, but you should enable them in config.

Wondering what to change in RT_SiteConfig.pm and can someone give me
an examples of how to ‘take’ ‘resolve’ tickets via email, I know how
to open new tickets in specific queue using mail.

Thanks. Askar

Gene LeDuc, GSEC
Security Analyst
San Diego State University

I am interested in that script

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAXFrom: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Gene LeDuc
Sent: Monday, November 26, 2007 11:29 AM
To: Asrai khn
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] take and resolve actions via email

Hi Askar,

This doesn’t answer your question about special features, but it does tell
you a way to do what you want to do.

I resolve tickets via e-mail using 3.6.3 with a fairly simple scrip. When
someone opens a ticket, I send out 2 e-mails. The first goes to the user
who opened it - they get login credentials so they can look at the
ticket. The second goes to the AdminCc list for the queue to notify them
that there’s a new ticket in the queue. If a reply comes in for that
ticket, and the sender is one of the AdminCc, and the first line of the
e-mail is “Ok”, then my scrip sets the ticket owner to the person who sent
the message and the status to resolved. Otherwise the message just gets
attached to the ticket. It would be simple to modify a scrip like that to
do a “take” as well.

If you’re interested in following this trail, let me know.

Regards,
Gene

At 06:55 AM 11/22/2007, Asrai khn wrote:

while reading RT3 FAQs found that …

A2: RT 3.5 has support for take and resolve actions in rt-mailgate
script, you can use them, but you should enable them in config.

Wondering what to change in RT_SiteConfig.pm and can someone give me an
examples of how to ‘take’ ‘resolve’ tickets via email, I know how to
open new tickets in specific queue using mail.

Thanks. Askar

Gene LeDuc, GSEC
Security Analyst
San Diego State University

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch
today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

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

At 08:48 AM 11/26/2007, Mark Fuller wrote:

I am interested in that script

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAX

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Gene LeDuc
Sent: Monday, November 26, 2007 11:29 AM
To: Asrai khn
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] take and resolve actions via email

Hi Askar,

This doesn’t answer your question about special features, but it does tell
you a way to do what you want to do.

I resolve tickets via e-mail using 3.6.3 with a fairly simple scrip. When
someone opens a ticket, I send out 2 e-mails. The first goes to the user
who opened it - they get login credentials so they can look at the
ticket. The second goes to the AdminCc list for the queue to notify them
that there’s a new ticket in the queue. If a reply comes in for that
ticket, and the sender is one of the AdminCc, and the first line of the
e-mail is “Ok”, then my scrip sets the ticket owner to the person who sent
the message and the status to resolved. Otherwise the message just gets
attached to the ticket. It would be simple to modify a scrip like that to
do a “take” as well.

If you’re interested in following this trail, let me know.

Regards,
Gene

At 06:55 AM 11/22/2007, Asrai khn wrote:

while reading RT3 FAQs found that …

A2: RT 3.5 has support for take and resolve actions in rt-mailgate
script, you can use them, but you should enable them in config.

Wondering what to change in RT_SiteConfig.pm and can someone give me an
examples of how to ‘take’ ‘resolve’ tickets via email, I know how to
open new tickets in specific queue using mail.

Thanks. Askar

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Thanks is there a way to have it be a comment only so that only the admin
cc’s get it?

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAXFrom: Gene LeDuc [mailto:gleduc@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

At 08:48 AM 11/26/2007, Mark Fuller wrote:

I am interested in that script

Mark Fuller

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAX

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Gene
LeDuc
Sent: Monday, November 26, 2007 11:29 AM
To: Asrai khn
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] take and resolve actions via email

Hi Askar,

This doesn’t answer your question about special features, but it does
tell you a way to do what you want to do.

I resolve tickets via e-mail using 3.6.3 with a fairly simple scrip.
When someone opens a ticket, I send out 2 e-mails. The first goes to
the user who opened it - they get login credentials so they can look at
the ticket. The second goes to the AdminCc list for the queue to
notify them that there’s a new ticket in the queue. If a reply comes
in for that ticket, and the sender is one of the AdminCc, and the first
line of the e-mail is “Ok”, then my scrip sets the ticket owner to the
person who sent the message and the status to resolved. Otherwise the
message just gets attached to the ticket. It would be simple to modify
a scrip like that to do a “take” as well.

If you’re interested in following this trail, let me know.

Regards,
Gene

At 06:55 AM 11/22/2007, Asrai khn wrote:

while reading RT3 FAQs found that …

A2: RT 3.5 has support for take and resolve actions in rt-mailgate
script, you can use them, but you should enable them in config.

Wondering what to change in RT_SiteConfig.pm and can someone give me
an examples of how to ‘take’ ‘resolve’ tickets via email, I know how
to open new tickets in specific queue using mail.

Thanks. Askar

Gene LeDuc, GSEC
Security Analyst
San Diego State University

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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

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 FAXFrom: Gene LeDuc [mailto:gleduc@mail.sdsu.edu]
Sent: Monday, November 26, 2007 4:27 PM
To: Mark Fuller
Cc: rt-users@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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

This doesn’t answer your question about special features, but it does tell
you a way to do what you want to do.

I resolve tickets via e-mail using 3.6.3 with a fairly simple scrip. When
someone opens a ticket, I send out 2 e-mails. The first goes to the user
who opened it - they get login credentials so they can look at the
ticket. The second goes to the AdminCc list for the queue to notify them
that there’s a new ticket in the queue. If a reply comes in for that
ticket, and the sender is one of the AdminCc, and the first line of the
e-mail is “Ok”, then my scrip sets the ticket owner to the person who sent
the message and the status to resolved. Otherwise the message just gets
attached to the ticket. It would be simple to modify a scrip like that to
do a “take” as well.

If you’re interested in following this trail, let me know.

Hi Gene

Sure i was interesting and thanks for posting the script :slight_smile:

Btw being very new to RT i wonders where to put the script ?

Thanks.

Askar.

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);
}

  1. 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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 4:27 PM
To: Mark Fuller
Cc: rt-users@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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

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 FAXFrom: Gene LeDuc [mailto:gleduc@mail.sdsu.edu]
Sent: Tuesday, November 27, 2007 3:50 PM
To: Mark Fuller; Asrai khn
Cc: rt-users@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);
}

  1. 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

From: Gene LeDuc [ mailto:gleduc@mail.sdsu.edu
mailto:gleduc@mail.sdsu.edu]
Sent: Monday, November 26, 2007 4:27 PM
To: Mark Fuller
Cc: rt-users@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@mail.sdsu.edu
mailto:gleduc@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

I think you could make these changes in the scrip:

{ ### True if e-mail contains ‘ok’ - sets owner, resolves ticket
my $Transaction = $self->TransactionObj;
my $CreatorMail = $Transaction->CreatorObj->EmailAddress();
my $val = $Transaction->Type eq ‘Correspond’
&& $CreatorIdMail =~ /@foo.com/i
&& $Transaction->Content =~ /\bok\s/i;
return $val;
}

At 01:37 PM 11/27/2007, Mark Fuller wrote:

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

mailto:%@foo.com%@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<?xml:namespace prefix = o ns =
“urn:schemas-microsoft-com:office:office” />

BandTel Engineering

603-528-6538 Option 2

603-528-6937 FAX

-----Original Message-----
From: Gene LeDuc [mailto:gleduc@mail.sdsu.edu]
Sent: Tuesday, November 27, 2007 3:50 PM
To: Mark Fuller; Asrai khn
Cc: rt-users@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);
}

  1. 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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 4:27 PM
To: Mark Fuller
Cc: rt-users@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@mail.sdsu.edu]
Sent: Monday, November 26, 2007 12:26 PM
To: Mark Fuller
Cc: rt-users@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

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Hi Mark (and Askar),

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

Hi Gene

Thanks again what if we do not to sent user/password to user which created
the ticket will this script works without any change to it?

Here we do not sent out credentials to those who created ticket.

Regards, Askar

The stuff I supplied doesn’t send login credentials, or anything else in
particular. It just modifies a scrip so that it will not send an email (in
response to an incoming email) to non-AdminCcs if a specific custom field
exists in the ticket and has some value assigned to it.

If an email has user credentials in it and you don’t want them to be there,
just remove the code from that particular template. RT’s default autoreply
template does not include user credentials.

Gene

At 07:33 AM 11/29/2007, Asrai khn wrote:>On Nov 28, 2007 1:49 AM, Gene LeDuc <mailto:gleduc@mail.sdsu.edugleduc@mail.sdsu.edu> wrote:

Hi Mark (and Askar),

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

Hi Gene

Thanks again what if we do not to sent user/password to user which created
the ticket will this script works without any change to it?

Here we do not sent out credentials to those who created ticket.

Regards, Askar


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch
today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Gene LeDuc, GSEC
Security Analyst
San Diego State University