[rt-users] Storing custom field file to local file system

BJ Blanchard blabj at dainty.ca
Tue Jun 2 16:24:59 EDT 2009


I am writing a custom dhandler for a CMMS/Work Order system based on
RT/AT.

Essentially I have a Work Order Template (an OpenOffice ODT file with
user-defined fields) that I populate with custom fields from an RT
Ticket using command-line XMLstarlet tool.

Everything is working when I store my template document on the file
system..  ie. my $file = dirname($m->current_comp->source_file) .
'/MaintenanceWO.odt';

But I want to get the template document from an Asset Custom Field.

>From outside of RT, and using LWP::Simple - I can do this - which works:

  my $asset = RTx::AssetTracker::Asset->new($RT::SystemUser);
  my $cf = RT::CustomFieldValue->new($RT::SystemUser);

  $asset->Load("WO Template");
  $cf = $asset->CustomFieldValues("File")->First;

  my $id = $cf->Id;

  my $url = RT->Config->Get('WebPath') .
"/Download/CustomFieldValue/".$cf->Id.'/'.$cf->Content;
  getstore($url,"/tmp/temp.odt");


Unfortunately from within the dhandler it does not work.  There are
authentication issues.. ie. it returns the RT login html instead of the
template document.

I tried appending "?user=rtuser&pass=rtpassword" to the url, but no
luck.

Within RT itself, is there a "LWP::Simple::getstore" equivalent??

Or perhaps more easily put:  How do you extract a file from a custom
field and store it on the local file system?

Thanks,

-Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090602/6390adfe/attachment.htm>


More information about the rt-users mailing list