Source of new ticket: Web or email?

Is there any way, specifically in a scrip, to determine if the ticket
just created was done via the Web UI or via an email? I would like to
disable auto-replies for web transactions where the requestor is also
the principal (they get instant feedback; they don’t need or want the
additional email).

Thanks!

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

Is there any way, specifically in a scrip, to determine if the
ticket just created was done via the Web UI or via an email? I
would like to disable auto-replies for web transactions where the
requestor is also the principal (they get instant feedback; they
don’t need or want the additional email).

Ha! I spent some time doing this a couple of weeks ago… I came up
with this:

my $co = $self->TransactionObj->ContentObj;

if ($co->GetHeader(‘Received’)) { # came via email }

smime.p7s (2.47 KB)

Have a look at RT WIKI
http://wiki.bestpractical.com/index.cgi?OnCreateFromEmail

Best regards

Marouane HIMDI

Joe Casadonte a �crit :

To all,

I am trying to determine if a ticket is being created via E_mail and if 

so move the subject to a custom field named “Description”. I tried to
use this code as follows:

Custom condition: none

Custom action preparation code:

my $trans;
my $msgattr;
my $cf_obj;
my $cf_name;
my $cf_value;

set description

$cf_obj = RT::CustomField->new($RT::SystemUser);
$cf_name = “Description”;
$cf_value = $self->TicketObj->Subject();
$RT::Logger->debug( $self . " cf_value = ". $cf_value . “\n” );
$cf_obj->LoadByName( Name => $cf_name );
$RT::Logger->debug( “Loaded $cf_obj->Name = “. $cf_obj->Name() .”\n” );
$cf_obj->AddValueForObject( Object=>$self->TicketObj, Content=>$cf_value, );

determine source of transaction

$trans = $self->TransactionObj;
return 0 unless $trans->Type eq “Create”;
$msgattr = $trans->Message->First;
return 0 unless $msgattr;
return 1 if $msgattr->GetHeader(‘Received’);
return 0;

It isn't working for me. Can anyone find the problem in my code? Thanks.

Kenn
LBNL

Marouane HIMDI wrote:

At Thursday 2/15/2007 01:42 PM, Kenneth Crocker wrote:

To all,

I am
trying to determine if a ticket is being created via E_mail and if so
move the subject to a custom field named “Description”. I tried
to use this code as follows:

Custom condition: none

Custom action preparation code:

my $trans;

my $msgattr;

my $cf_obj;

my $cf_name;

my $cf_value;

set description

$cf_obj = RT::CustomField->new($RT::SystemUser);

$cf_name = “Description”;

$cf_value = $self->TicketObj->Subject();

$RT::Logger->debug( $self . " cf_value = ". $cf_value .
“\n” );

$cf_obj->LoadByName( Name => $cf_name );

$RT::Logger->debug( “Loaded $cf_obj->Name = “.
$cf_obj->Name() .”\n” );

$cf_obj->AddValueForObject( Object=>$self->TicketObj,
Content=>$cf_value, );

determine source of transaction

$trans = $self->TransactionObj;

return 0 unless $trans->Type eq “Create”;

$msgattr = $trans->Message->First;

return 0 unless $msgattr;

return 1 if $msgattr->GetHeader(‘Received’);

return 0;

It isn’t
working for me. Can anyone find the problem in my code? Thanks.

Kenn,

The code looks correct. In what way is it not working? Do you see
anything in the RT log? Have you tried putting logging statements in the
code to see how far it’s getting? Did you remember to set the condition
to ‘User Defined’ in the scrip definition?

Steve

Stephen,

Thanks for looking at this. Originally, the following code put the 

subject info into CF “Description” and it worked:

Custom condition: none

Custom action preparation code:

my $cf_obj;
my $cf_name;
my $cf_value;

$cf_obj = RT::CustomField->new($RT::SystemUser);
$cf_name = “Description”;
$cf_value = $self->TicketObj->Subject();

$RT::Logger->debug( $self . " cf_value = ". $cf_value . “\n” );

$cf_obj->LoadByName( Name => $cf_name );
$RT::Logger->debug( “Loaded $cf_obj->Name = “. $cf_obj->Name() .”\n” );
$cf_obj->AddValueForObject( Object => $self->TicketObj, Content =>
$cf_value, );
return 1;

However, I modified it (see earlier code) to do this only if it was an 

E_mail ticket. I have the condition set to “OnCreate” and the action as
"User Defined" and the code in the custom action preparation area. Upon
execution, the ticket is created via E_mail but the description is
blank, whereas before it was the same as the subject. I have not
accessed the logs (another department and they are busy) so I’ll try
that next, maybe I’ll get a clue there. Thanks again.

Kenn
LBNL

Stephen Turner wrote: