Changing status/owner via email pt2

hi
I got some help the other week from Ruslan and wanted
to ask a quick query. It was regarding changing
status/owner via email.

Code is at the bottom of the email and works fine. My
query is that with the scrips set up it goes out to
the user as its seen the same as a normal reply email
on how to fix the problem. I’d rather if possible not
email out Set-Status etc . Is there a way ?
Thanks for any pointers.
Elaine

Try next commit code:
my $content =
$self->TransactionObj->Attachments->First->Content;
if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m ) {

    $self->TicketObj->SetOwner( $1 );

}
if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m ) {

    $self->TicketObj->SetStatus( $1 );

}
1;

And put into mail body next line:
Set-Status: rejected
Don’t add empty spaces before Set-Status

ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Elaine, yeah, that should be fixed, use next code:

my $AttachObj = $self->TransactionObj->Attachments->First;

go out if content is not text!

unless( $AttachObj->ContentType =~ /^text/ ) {
return 1;
}

my $content = $AttachObj->Content;
if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m ) {
$self->TicketObj->SetOwner( $1 );
}
if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m ) {
$self->TicketObj->SetStatus( $1 );
}

strip special commands from email content

$content =~ s/^\QSet-Status:\E\s*(\S+)\s*$//gm;
$content =~ s/^\QSet-Owner:\E\s*(\S+)\s*$//gm;

silently overwrite attachment content

$AttachObj->__Set( Field => ‘Content’, Value => $content );

1;

This code is not tested but should work. If not then post data from logs
to the list.
And please write instructions how to set up this code on the wiki:
http://wiki.bestpractical.com/index.cgi?SetTicketPropertiesViaMail
I’ve created link on this page from
http://wiki.bestpractical.com/index.cgi?Contributions

This scrip has drawbacks that are not addressed yet. For example all
transactions this scrip creates comes from RT System user not user who
sent email. This is bad and should be fixed because allow anybody who
has right create/reply/comment on ticket to set status and owner.

			Best regards. Ruslan.

Elaine . wrote:

hi
I tried the code below, no errors in the log, although
it strips out in the fault the Set-Owner or Set-Status
(good) that is logged, there are no emails sent as the
only scrip i have set is user defined and nothing in
that says send an email ? If i then do another scrip
as “on correspond, reply to requestor with template
correspondence” then nothing gets stripped as its in
the other scrip ? Maybe i’m misunderstanding how i
should be setting things up ?

my $AttachObj =
$self->TransactionObj->Attachments->First;

go out if content is not text!

unless( $AttachObj->ContentType =~ /^text/ ) {

    return 1;

}

my $content = $AttachObj->Content;
if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m ) {

     $self->TicketObj->SetOwner( $1 );

}
if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m ) {

     $self->TicketObj->SetStatus( $1 );

}

strip special commands from email content

$content =~ s/^\QSet-Status:\E\s*(\S+)\s*$//gm;
$content =~ s/^\QSet-Owner:\E\s*(\S+)\s*$//gm;

silently overwrite attachment content

$AttachObj->__Set( Field => ‘Content’, Value =>
$content );

1;

ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

Elaine . wrote:

hi
I tried the code below, no errors in the log, although
it strips out in the fault the Set-Owner or Set-Status
(good) that is logged, there are no emails sent as the
What is logged?

only scrip i have set is user defined and nothing in
that says send an email ? If i then do another scrip
This scrip can’t send email, it change properties. So use blank template
with it.

as “on correspond, reply to requestor with template
correspondence” then nothing gets stripped as its in
the other scrip ? Maybe i’m misunderstanding how i
Hmm. Scrip execution order is unpredictable :frowning: in RT. And this is
very-very bad. Possible that RT runs “notify” first and only then runs
your custom one. Move code from custom commit block to custom prepare block.

hi
Thanks, I got it all sorted and explained in the wiki
http://wiki.bestpractical.com/index.cgi?SetTicketPropertiesViaMail

Basically putting it in the prepartion code part of
the scrip and having the scrip to email out AFTER the
email cleanup happened.
Thanks a lot !
Elaine

— “Ruslan U. Zakirov” Ruslan.Zakirov@acronis.com
wrote:

Elaine . wrote:

hi
I tried the code below, no errors in the log,
although
it strips out in the fault the Set-Owner or
Set-Status
(good) that is logged, there are no emails sent as
the
What is logged?

only scrip i have set is user defined and nothing
in
that says send an email ? If i then do another
scrip
This scrip can’t send email, it change properties.
So use blank template
with it.

as “on correspond, reply to requestor with
template
correspondence” then nothing gets stripped as its
in
the other scrip ? Maybe i’m misunderstanding how i
Hmm. Scrip execution order is unpredictable :frowning: in
RT. And this is
very-very bad. Possible that RT runs “notify” first
and only then runs
your custom one. Move code from custom commit block
to custom prepare block.

should be setting things up ?

my $AttachObj =
$self->TransactionObj->Attachments->First;

go out if content is not text!

unless( $AttachObj->ContentType =~ /^text/ ) {

    return 1;

}

my $content = $AttachObj->Content;
if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m )
{

     $self->TicketObj->SetOwner( $1 );

}
if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m )
{

     $self->TicketObj->SetStatus( $1 );

}

strip special commands from email content

$content =~ s/^\QSet-Status:\E\s*(\S+)\s*$//gm;
$content =~ s/^\QSet-Owner:\E\s*(\S+)\s*$//gm;

silently overwrite attachment content

$AttachObj->__Set( Field => ‘Content’, Value =>
$content );

1;

ALL-NEW Yahoo! Messenger - all new features - even
more fun! http://uk.messenger.yahoo.com


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

RT Administrator and Developer training is coming
to your town soon! (Boston, San Francisco, Austin,
Sydney) Contact training@bestpractical.com for
details.

Be sure to check out the RT Wiki at
http://wiki.bestpractical.com

ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com

I didn’t know but there is other similar extension on
http://www.usit.uio.no/it/rt/modifications.html

Elaine . wrote:

hi
Thanks i’ve bookmarked it for next time i feel like
extending it. :wink:
Elaine

— “Ruslan U. Zakirov” Ruslan.Zakirov@acronis.com
wrote:

I didn’t know but there is other similar extension
on
http://www.usit.uio.no/it/rt/modifications.html

Elaine . wrote:

hi
Thanks, I got it all sorted and explained in the
wiki

http://wiki.bestpractical.com/index.cgi?SetTicketPropertiesViaMail

Basically putting it in the prepartion code part
of
the scrip and having the scrip to email out AFTER
the
email cleanup happened.
Thanks a lot !
Elaine

— "Ruslan U. Zakirov"
Ruslan.Zakirov@acronis.com
wrote:

Elaine . wrote:

hi
I tried the code below, no errors in the log,

although

it strips out in the fault the Set-Owner or

Set-Status

(good) that is logged, there are no emails sent
as

the
What is logged?

only scrip i have set is user defined and nothing

in

that says send an email ? If i then do another

scrip
This scrip can’t send email, it change properties.
So use blank template
with it.

as "on correspond, reply to requestor with

template

correspondence" then nothing gets stripped as its

in

the other scrip ? Maybe i’m misunderstanding how
i

Hmm. Scrip execution order is unpredictable :frowning: in
RT. And this is
very-very bad. Possible that RT runs "notify"
first

and only then runs
your custom one. Move code from custom commit
block

to custom prepare block.

should be setting things up ?

my $AttachObj =
$self->TransactionObj->Attachments->First;

go out if content is not text!

unless( $AttachObj->ContentType =~ /^text/ ) {

   return 1;

}

my $content = $AttachObj->Content;
if( $content =~ m/^\QSet-Owner:\E\s*(\S+)\s*$/m )

{

    $self->TicketObj->SetOwner( $1 );

}
if( $content =~ m/^\QSet-Status:\E\s*(\S+)\s*$/m
)

{

    $self->TicketObj->SetStatus( $1 );

}

strip special commands from email content

$content =~ s/^\QSet-Status:\E\s*(\S+)\s*$//gm;
$content =~ s/^\QSet-Owner:\E\s*(\S+)\s*$//gm;

silently overwrite attachment content

$AttachObj->__Set( Field => ‘Content’, Value =>
$content );

1;

ALL-NEW Yahoo! Messenger - all new features -
even

more fun! http://uk.messenger.yahoo.com


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

RT Administrator and Developer training is coming

to your town soon! (Boston, San Francisco, Austin,
Sydney) Contact training@bestpractical.com for
details.

Be sure to check out the RT Wiki at

http://wiki.bestpractical.com

ALL-NEW Yahoo! Messenger - all new features - even
more fun! http://uk.messenger.yahoo.com

ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com