First time writing scrips, and having problems with auto-resolving and setting transation's timetaken

hi
first of all - i’m using rt 3.0.6. (will be upgradeing very soon, but
right now it’s all i have).

i wanted to write a scrip which will allow me to resolve tickets and set
"timetaken" per transaction in mails i send to rt (which later are added
as correspondence to tickets).
so i wrote this scrip:

#v+
my $sContent = $self->TransactionObj->ContentObj->Content;
my $sCreator = $self->TransactionObj->CreatorObj->EmailAddress;

return 1 unless $sCreator =~ /^[a-z.]+@OUR_DOMAIN$/;

$sContent =~ s/\s*$//; # this makes $sContent
$sContent =~ s/^.*\n//s; # Contain only last non-empty line
return 1 unless $sContent =~ s/^xx:\s+//;

if ($sContent =~ s/(^|\s+)w:(\d+)($|\s+)/ /) {
my $tic = $self->TicketObj;
my @a = $tic->SetTimeWorked( $tic->TimeWorked + $2 );

}
if ($sContent =~ s/(^|\s+)s:(resolved|stalled|rejected)($|\s+)/ /) {
$self->TicketObj->SetStatus($2);
}

return 1;
#v-

looks simple.
1st.
i would like to set timetaken per transation, but when i tried:
$self->TransactionObj->SetTimeTaken($2);
i got error: Immutable Field.

is there anything i can do without modifiyng .pm’s (i know about
writing _Local.pm’s, but i dont like the idea).

2nd (and more important).
When i do SetStatus this way - it works, BUT - then goes global scrip:
"On Correspond Open Tickets with template Blank"
which is (as far as i know) standard in rt.

i like this global scrip so i’m not goging to turn this off, but maybe
there is a way to temporary disable it when i setstatus otherwise?

i really hope some of you can help me, and sorry for my english.

depesz

hubert lubaczewski
Network Operations Center
Eo Networks Sp. z o.o.

hubert lubaczewski wrote:

hi
first of all - i’m using rt 3.0.6. (will be upgradeing very soon, but
right now it’s all i have).

i wanted to write a scrip which will allow me to resolve tickets and set
“timetaken” per transaction in mails i send to rt (which later are added
as correspondence to tickets).
so i wrote this scrip:

#v+
my $sContent = $self->TransactionObj->ContentObj->Content;
my $sCreator = $self->TransactionObj->CreatorObj->EmailAddress;

return 1 unless $sCreator =~ /[1]+@OUR_DOMAIN$/;

$sContent =~ s/\s*$//; # this makes $sContent
$sContent =~ s/^.*\n//s; # Contain only last non-empty line
return 1 unless $sContent =~ s/^xx:\s+//;

if ($sContent =~ s/(^|\s+)w:(\d+)($|\s+)/ /) {
my $tic = $self->TicketObj;
my @a = $tic->SetTimeWorked( $tic->TimeWorked + $2 );

}
if ($sContent =~ s/(^|\s+)s:(resolved|stalled|rejected)($|\s+)/ /) {
$self->TicketObj->SetStatus($2);
}

return 1;
#v-

looks simple.
1st.
i would like to set timetaken per transation, but when i tried:
$self->TransactionObj->SetTimeTaken($2);
i got error: Immutable Field.
I’m not shure that you can set it without breaking RT calcs on this
field, but anyway you can use low level call _Set.

is there anything i can do without modifiyng .pm’s (i know about
writing _Local.pm’s, but i dont like the idea).

2nd (and more important).
When i do SetStatus this way - it works, BUT - then goes global scrip:
“On Correspond Open Tickets with template Blank”
which is (as far as i know) standard in rt.
you can incorporate this global scrip into your action.
if ($sContent =~ s/(^|\s+)s:(resolved|stalled|rejected)($|\s+)/ /) {
$self->TicketObj->SetStatus($2);
} else {
$self->TicketObj->SetStatus(‘open’);
}

Or add custom condition on this global scrip that check if mail contain
this special instruction.


  1. a-z. ↩︎

hubert lubaczewski wrote:

I’m not shure that you can set it without breaking RT calcs on this
field, but anyway you can use low level call _Set.

calling _Set returns (0, ‘Immutable Object’) and, as far as i can see,
is hardcoded into RT/Transaction_Overlay.pm
Ooops. ‘__Set’ I mean, but you don’t need it I think. Incorporate this
directly into ticket’s TimeTaken.