[Rt-devel] Attachments via the CLI

Mike Howsden mhowsden at gmail.com
Fri Sep 16 15:56:08 EDT 2005


Hey All,

I'm trying to get attachments working via the CLI.  I have an external
Perl CGI script which I've been using for a simple web based form so
customers can send tickets via that method.  I would like to add a
field for attachments and then be able to use the CLI to insert that
attachment into RT.

Does RT's CLI interface currently have this feature and I'm just
missing it or does it still need to be implemented.  If the latter we
have some limited money to help get that feature implemented.

here's the script i'm using currently that I would like to add the
attachment option to.

Thanks in Advance for any help/advice.  

Mike

# This script creates a support ticket
#  From the patient modify screen.
#  return code 1 == success, 0 == error
#
 use lib "/usr/local/rt3/lib";

 use RT::Interface::CLI;
 use RT;
 RT::LoadConfig();
 RT::Init();
 use RT::Ticket;
 use RT::CurrentUser;
 my $CurrentUser = RT::Interface::CLI::GetCurrentUser();
 use MIME::Entity;

 #code added for cgi form processing
 my $tags = GT::Template->tags;
  
 my $return_status = 0;
 my $subject = "Update Patient Information:";
 my $provider_id = $tags->{ProviderAHSID};
 my $insured_id = $tags->{InsuredID};
 my $patient_id = $tags->{PatientID};
 my $eclipse_id = $tags->{EclipseID};
 my $provider_email = $tags->{ProviderEmail};
 my $patient_name = substr($patient_id, 7);

 my $body = $tags->{PatientChanges};
               *
 if($provider_id eq '' || $patient_id eq '' || $insured_id eq ''){
    $return_status = "a Patient ID, Insured ID or Provider ID is
missing from the
 previous form.";
    return $return_status;
 }
 else{
   $return_status = 1;
 }

 my $ticket = new RT::Ticket($CurrentUser);
 my $ticket_body = MIME::Entity->build(Data => $body, Type => 'text/plain');
 my %ticket_vals = ( Queue => 'Patientmod',
                       Subject => "$subject $patient_name",
                       Owner => 'tammy',
                       Requestor => $provider_email,
                       InitialPriority => '10',
                       FinalPriority => '20',
                       MIMEObj => $ticket_body,
               *
 # note, these field numbers are found from looking at the page source
 # on a particular custom field in the RT interface
                       'CustomField-1' => $patient_id,
                       'CustomField-2' => $provider_id,
                       'CustomField-3' => $insured_id,
                       'CustomField-4' => $eclipse_id
                     );
   my ($id, $transaction_object, $err) = $ticket->Create(%ticket_vals);
   print STDERR $err . "\n" if $err;
               *
 if ($err){return $err;}
 else{return $return_status}
 }


More information about the Rt-devel mailing list