NAME
RT-Extension-Assets-Import-CSV - RT Assets Import from CSV
INSTALLATION
- perl Makefile.PL
- make
- make install
-
May need root permissions
- Edit your /opt/rt4/etc/RT_SiteConfig.pm
-
Add this line:
Set(@Plugins, qw(RT::Extension::Assets::Import::CSV));
or add
RT::Extension::Assets::Import::CSV
to your existing@Plugins
line.See "CONFIGURATION", below, for the remainder of the required configuration.
CONFIGURATION
The following configuration would be used to import a three-column CSV of assets, where the column titled serviceTag
is unique:
Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
'Service Tag' => 'serviceTag',
'Location' => 'building',
'Serial #' => 'serialNo',
);
Constant values
If you want to set an RT column or custom field to a static value for all imported assets, proceed the "CSV field name" (right hand side of the mapping) with a slash, like so:
Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
'Service Tag' => 'serviceTag',
'Location' => 'building',
'Serial #' => 'serialNo',
'Catalog' => \'Hardware',
);
Every imported asset will now be added to the Hardware catalog in RT. This feature is particularly useful for setting the asset catalog, but may also be useful when importing assets from CSV sources you don't control (and don't want to modify each time).
Computed values
You may also compute values during import, by passing a subroutine reference as the value in the %AssetsImportFieldMapping
. This subroutine will be called with a hash reference of the parsed CSV row.
Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
'Service Tag' => 'serviceTag',
'Location' => 'building',
'Weight' => sub { $_[0]->{"Weight (kg)"} || "(unknown)" },
);
Numeric identifiers
If you are already using a numeric identifier to uniquely track your assets, and wish RT to take over handling of that identifier, you can choose to leave $AssetsImportUniqueCF
unset, and assign to id
in the %AssetsImportFieldMapping
:
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
'id' => 'serviceTag',
'Location' => 'building',
'Serial #' => 'serialNo',
);
This requires that, after the import, RT becomes the generator of all asset ids. Otherwise, asset id conflicts may occur.
AUTHOR
sunnavy <sunnavy@bestpractical.com>
BUGS
All bugs should be reported via http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Assets-Import-CSV or bug-RT-Extension-Assets-Import-CSV@rt.cpan.org.
LICENSE AND COPYRIGHT
This software is Copyright (c) 2012 by Best Practical Solutions
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991