Scrip: how to check if correspondence from requestor

Hello,

I want to use a scrip to change the status of a ticket to “open” if
the current status is “reqappr” and RT receives an email from the
requester.

Can anyone help me fill in the following <???> (or make other
corrections if needed):

Description: OnCorrespondFromReqReReqaddrTicket
Condition: UserDefined
Action: UserDefined
Template: Global template: Blank
Stage: TransactionCreate

Custom Condition:
if (
$self->TransactionObj->Type eq "Correspond"
and
$self->TicketObj->Status eq "reqappr"
and
<???> eq $self->TicketObj->RequestorAddresses;
)
{
$self->TicketObj()->setStatus(‘open’);
return(1);
} else {
return(undef);
}

Custom action preparation code:
return 1;

Custom action cleanup code:

Thanks,
Phil Lawrence

Hi Phil,

I’ve never used non-standard status values, but if they work just like
“normal” status values then this should do it:

User-defined condition:
{ ### True if e-mail is from Requestor
my $Transaction = $self->TransactionObj;
my $CreatorId = $Transaction->CreatorObj->Id;
my $Ticket = $self->TicketObj;
my $val = $Transaction->Type eq ‘Correspond’
&& $Ticket->Status eq “reqappr”
&& $Ticket->CreatorObj->Id == $CreatorId;
return $val;
}

Custom action (prep):
return 1;

Custom action (cleanup):
$self->TicketObj->SetStatus(“open”);

Regards,
Gene

At 11:25 AM 9/13/2007, Phil Lawrence wrote:

Hello,

I want to use a scrip to change the status of a ticket to “open” if
the current status is “reqappr” and RT receives an email from the
requester.

Can anyone help me fill in the following <???> (or make other
corrections if needed):

Description: OnCorrespondFromReqReReqaddrTicket
Condition: UserDefined
Action: UserDefined
Template: Global template: Blank
Stage: TransactionCreate

Custom Condition:
if (
$self->TransactionObj->Type eq “Correspond”
and
$self->TicketObj->Status eq “reqappr”
and
<???> eq $self->TicketObj->RequestorAddresses;
)
{
$self->TicketObj()->setStatus(‘open’);
return(1);
} else {
return(undef);
}

Custom action preparation code:
return 1;

Custom action cleanup code:

Thanks,
Phil Lawrence


The rt-users Archives

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

If a ticket is created by requestor Alice but with Bob and Carol as
requestors also (e.g. Alice sent the ticket-opening email with a
recipient list that included Bob and Carol):

Won’t “$Ticket->CreatorObj->Id == $CreatorId” only match on transactions
initiated by Alice?

If the intent is to fire on email from any of the Requestors (as opposed
to email from the originator) then this scrip falls slightly short.
You’ll need to include a function that walks the Requestors list and
compares $CreatorId with each Requestor in turn, returning true if it
finds a match.On Thu, 2007-09-13 at 11:44 -0700, Gene LeDuc wrote:

I’ve never used non-standard status values, but if they work just
like
“normal” status values then this should do it:

User-defined condition:
{ ### True if e-mail is from Requestor
my $Transaction = $self->TransactionObj;
my $CreatorId = $Transaction->CreatorObj->Id;
my $Ticket = $self->TicketObj;
my $val = $Transaction->Type eq ‘Correspond’
&& $Ticket->Status eq “reqappr”
&& $Ticket->CreatorObj->Id == $CreatorId;
return $val;
}

Custom action (prep):
return 1;

Custom action (cleanup):
$self->TicketObj->SetStatus(“open”);

Regards,
Gene

/Ole Craig
Security Engineer
Team lead, customer support

ocraig@stillsecure.com
303-381-3802 main support line
303-381-3824 my voicemail
303-381-3880 fax

www.stillsecure.com

You’re right, my scrip fires when the e-mail is from the originator of the
ticket. In our system, the originator is always the only requestor, so I
equated “requestor” to “originator” when I read the original.

At 01:15 PM 9/13/2007, Ole Craig wrote:

If a ticket is created by requestor Alice but with Bob and Carol as
requestors also (e.g. Alice sent the ticket-opening email with a
recipient list that included Bob and Carol):

Won’t “$Ticket->CreatorObj->Id == $CreatorId” only match on transactions
initiated by Alice?

If the intent is to fire on email from any of the Requestors (as opposed
to email from the originator) then this scrip falls slightly short.
You’ll need to include a function that walks the Requestors list and
compares $CreatorId with each Requestor in turn, returning true if it
finds a match.

I’ve never used non-standard status values, but if they work just
like
“normal” status values then this should do it:

User-defined condition:
{ ### True if e-mail is from Requestor
my $Transaction = $self->TransactionObj;
my $CreatorId = $Transaction->CreatorObj->Id;
my $Ticket = $self->TicketObj;
my $val = $Transaction->Type eq ‘Correspond’
&& $Ticket->Status eq “reqappr”
&& $Ticket->CreatorObj->Id == $CreatorId;
return $val;
}

Custom action (prep):
return 1;

Custom action (cleanup):
$self->TicketObj->SetStatus(“open”);

Regards,
Gene


/Ole Craig
Security Engineer
Team lead, customer support

ocraig@stillsecure.com
303-381-3802 main support line
303-381-3824 my voicemail
303-381-3880 fax

www.stillsecure.com

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Hi Phil,

To correct my previous post, try this for your condition code:

my $ReqList = $self->TicketObj->Requestors->MemberEmailAddressesAsString;
my $Sender = $self->TransactionObj->CreatorObj->EmailAddress;
return $self->TransactionObj->Type eq “Correspond”
&& $self->TicketObj->Status eq “reqappr”
&& $ReqList =~ /$Sender/;

You just grab the list of requestor e-mail addresses and see if the
sender’s address is one of them.

Regards,
Gene

At 11:25 AM 9/13/2007, Phil Lawrence wrote:

Hello,

I want to use a scrip to change the status of a ticket to “open” if
the current status is “reqappr” and RT receives an email from the
requester.

Can anyone help me fill in the following <???> (or make other
corrections if needed):

Description: OnCorrespondFromReqReReqaddrTicket
Condition: UserDefined
Action: UserDefined
Template: Global template: Blank
Stage: TransactionCreate

Custom Condition:
if (
$self->TransactionObj->Type eq “Correspond”
and
$self->TicketObj->Status eq “reqappr”
and
<???> eq $self->TicketObj->RequestorAddresses;
)
{
$self->TicketObj()->setStatus(‘open’);
return(1);
} else {
return(undef);
}

Custom action preparation code:
return 1;

Custom action cleanup code:

Thanks,
Phil Lawrence


The rt-users Archives

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

Hi Phil,

To correct my previous post, try this for your condition code:

my $ReqList =
$self->TicketObj->Requestors->MemberEmailAddressesAsString;
my $Sender = $self->TransactionObj->CreatorObj->EmailAddress;
return $self->TransactionObj->Type eq “Correspond”
&& $self->TicketObj->Status eq “reqappr”
&& $ReqList =~ /$Sender/;

You just grab the list of requestor e-mail addresses and see if the
sender’s address is one of them.

ObPerlPedant: That’ll still be a little loose, you might want to anchor
your regex. If your sender is “john.doe@hotmail.com” the code below
would still match “not.the.real.john.doe@hotmail.com” – a corner case,
yes, but one with a nonzero chance of occurring given the way people
tend to construct accounts at some of the free webmail providers.

A quick’n’dirty fix might be something like this:

$ReqList =~ /^(.*,)$Sender[,$]/;

/Ole Craig
Security Engineer
Team lead, customer support

ocraig@stillsecure.com
303-381-3802 main support line
303-381-3824 my voicemail
303-381-3880 fax

www.stillsecure.com

your regex. If your sender is “john.doe@hotmail.com” the code below

Arrgh.

ObDirectionalPedant: s/below/above/

:-/

/Ole Craig
Security Engineer
Team lead, customer support

ocraig@stillsecure.com
303-381-3802 main support line
303-381-3824 my voicemail
303-381-3880 fax

www.stillsecure.com

I want to use a scrip to change the status of a ticket to “open” if
the current status is “reqappr” and RT receives an email from the
requester.

The Transaction object (I think) has an IsInbound method. Look into
that…

Regards,

joe
Joe Casadonte
joe.casadonte@oracle.com

========== ==========
== The statements and opinions expressed here are my own and do not ==
== necessarily represent those of Oracle Corporation. ==
========== ==========