Re: [rt-users] RT-Assets-Import-CSV surprises

2014-02-18 Thread Alex Vandiver
On Sat, 2014-02-08 at 14:37 +0100, Joop wrote:
> Still trying out new things :-)
> Found another thing which I think is a shortcut in the documentation. 
> [snip]
> Nowhere in the docs it is mentioned that you need to put CF. in front of 
> CustomFields.

Thanks for the catch.  I've just released version 1.1 which fixes this.
 - Alex

-- 
RT Training London, March 19-20 and Dallas May 20-21
http://bestpractical.com/training


[rt-users] RT-Assets-Import-CSV surprises

2014-02-08 Thread Joop

Hi All,

Still trying out new things :-)
Found another thing which I think is a shortcut in the documentation. 
Quoting one of the examples:

Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
'Service Tag'=> 'serviceTag',
'Location'   => 'building',
'Serial #'   => 'serialNo',
'Catalog'=> \'Hardware',
);

As I see it both Location and Serial # are Asset CustomFields and not 
one of the basic fields like id,Name,Description. Using this as an 
example I tried to import our UPS Catalog which looks like the following:
id,Name,Description,Status,Type,UPS Batt replaced,UPS Firmware 
revision,UPS Serial Number
553,wag-ups1,APC SmartUPS 
3000,production,BackupPower,2005-08-17,666.6.l,JS0534006874


With the following config part it will import the assets but not the 
last 3 columns which are the CF's of this type.


Set( $AssetsImportUniqueCF, undef );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
  'id' => 'id',
  'Name'   => 'Name',
  'Description'   => 'Description',
  'Catalog' =>\'BackupPower',
  'UPS Batt replaced'   => 'UPS Batt replaced',
  'UPS Firmware revision'   => 'UPS Firmware revision',
  'UPS Serial Number'   => 'UPS Serial Number',
   );

Looking at the output of debug shows that it sees the last 3 columns but 
it doesn't do anything with it. Putting some prints in CSV.pm and 
looking at the code I found out that the config should read:


Set( $AssetsImportUniqueCF, undef );
Set( %AssetsImportFieldMapping,
# 'RT custom field name' => 'CSV field name'
  'id' => 'id',
  'Name'   => 'Name',
  'Description'   => 'Description',
  'Catalog' =>\'BackupPower',
  'CF.UPS Batt replaced'   => 'UPS Batt replaced',
  'CF.UPS Firmware revision'   => 'UPS Firmware revision',
  'CF.UPS Serial Number'   => 'UPS Serial Number',
   );

Running the importer with --update will indeed now update the last 3 
columns.


Nowhere in the docs it is mentioned that you need to put CF. in front of 
CustomFields.


Joop