[rt-users] Adding New Transaction from scrip

Kory Prince korylprince at gmail.com
Thu Apr 19 15:04:50 EDT 2012


> You want to use the _NewTransaction method available on Records.
> You can trace through the Correspond method on Tickets to get a sense
> of how it's typically used.
>
> -kevin

Thanks Kevin.
Now correct if I'm wrong, but in order to have my own transaction
type, I would have to Edit Transaction.pm (or do a local copy on top
of it) to add it. What I eventually decided on was just adding a
comment from the system user. Here is my final script for anyone
interested:

#Taken partly from
http://kermit.yaxs.net/post/2061563927/request-tracker-quick-n-dirty-sending-sms-on-change

# load the ticket, owner and user object
my $Ticket = $self->TicketObj;
my $OwnerID = $self->TicketObj->Owner;
my $user = RT::User->new($RT::SystemUser);

# set the requestor email and ticket subject - will be used in the SMS
my $Requestor = $Ticket->RequestorAddresses;
my $Subject = $Ticket->Subject;

# load owners details and grab the mobile number from RT
$user->Load($OwnerID);
my $OwnerMobileNumber = $user->MobilePhone;

# check if we have a mobile number for the new owner, leave a log
message and quit if we dont
if ( !$OwnerMobileNumber ) {
  $RT::Logger->info ( 'Not sending notification SMS - no mobile number
found for owner');
  return 1;
}

# some logging so we can check it's working
$RT::Logger->info ( 'Sending SMS to '.$OwnerMobileNumber.', ticket
subject is '.$Ticket->Subject.' requested by
'.$Ticket->RequestorAddresses );

# ticket id
my $url = $RT::WebURL . "m/ticket/show?id=" . $Ticket->Id;

# and backticks to exec the sms script
`python /opt/notify.py \"$OwnerMobileNumber\" \"Ticket assigned:\n
$Requestor: $Subject\" \"$url\"`;
$self->TicketObj->Comment(
Content=>"Outgoing SMS Sent:\nTicket assigned:\n $Requestor: $Subject"
);
return 1;

Thanks
Kory Prince
Bullard ISD



More information about the rt-users mailing list