Assigning HeldBy users during Asset Import

Hi All

I have been playing around with RT for the last few weeks now and am trying
to import assets from an inventory I exported to a CSV file. The assets
successfully import but I am unable to fill the HeldBy field for any assets,
seeing the following warning when running the import ;

‘Role name HeldBy must be single-value for column Username, skipping’

My current configuration is RT 4.27 with RT-Authen-ExternalAuth-0.21,
Extension-LDAPImport-0.35, Extension-Assets-1.01 and
Extension-Assets-Import-CSV-1.3. I have connected the ExternalAuth to my
local AD and successfully imported all the domain users as unprivileged
users. I am able to assign any of these users to the HeldBy role under the
People tab of an Asset.

Here is the snippet from RT_SiteConfig.pm for the field mapping I am using;

Set( $AssetsImportUniqueCF, ‘Key Number’ );
Set( %AssetsImportFieldMapping,
‘Catalog’ => 'Keys’,
‘Name’ => ‘KeyNumber’,
‘Description’ => ‘EmployeeName’,
‘Status’ => 'in-use’,
‘HeldBy’ => ‘Username’,
‘CF.Department’ => ‘Department’,
‘CF.Issue Date’ => ‘Issued’,
‘CF.Username’ => ‘Username’,
‘CF.Issued To’ => ‘EmployeeName’,
‘CF.Key Level’ => ‘KeyLevel’,
‘CF.Key Way’ => ‘Keyway’,
‘CF.Key Number’ => ‘KeyNumber’,
‘CF.Other Info’ => ‘Username’,
);

Is there something I am missing or is this function not available?

In a related test, I am not able to assign a HeldBy user using the Bulk
Update feature either.

Thanks for any insight or solution to this.

View this message in context: http://requesttracker.8502.n7.nabble.com/Assigning-HeldBy-users-during-Asset-Import-tp58502.html

‘Role name HeldBy must be single-value for column Username, skipping’

For no particular reason, the code requires that you assign to a
single-value Role and disallows roles that could contain multiple
people.

In the case of Assets, this means you could set Owner, but not Held
By. This seems like an oversight. You can probably safely delete
that check from CSV.pm and try importing, but it’ll only allow a
single Held By user to be added. We’d need to define a convention for
having multiple people in that single column, possibly doing it by
email address which is easily parseable with tools, but right now that
column only goes by username (or user id).

Try tweaking the code and definitely file a bug about this because it
feels like an accidental oversight.

-kevin

Hi Kevin

Thanks for the response. I took a look at
/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/
CSV.PM and removed the check you suggested by commenting out lines 64 thru
67;

#if ( not RT::Asset->Role($fieldname)->{Single}) {

RT->Logger->warning( "Role name $fieldname must be single-value for

“._column($field2csv->{$fieldname}).”, skipping");

delete $field2csv->{$fieldname};

#}

Instead of the single warning I got one for each asset I tried to update
that had a username to be placed in the HeldBy field;

[error]: Failed to set HeldBy to mkyser for row 5408: No valid Type
specified
(/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/CSV.pm:178)

When I tried using ‘Owner’ instead of ‘HeldBy’ I got the same results.

I will see what it takes to submit a bug report like you suggested, then
submit one.

I am seeing similar things when I try to use the Bulk Update feature with
HeldBy, no error message but no change in HeldBy either.

Thanks again.

MitchOn Wed, Sep 17, 2014 at 11:44 AM, Kevin Falcone falcone@bestpractical.com wrote:

On Fri, Sep 12, 2014 at 10:15:19AM -0700, mkyser wrote:

‘Role name HeldBy must be single-value for column Username, skipping’

For no particular reason, the code requires that you assign to a
single-value Role and disallows roles that could contain multiple
people.

In the case of Assets, this means you could set Owner, but not Held
By. This seems like an oversight. You can probably safely delete
that check from CSV.pm and try importing, but it’ll only allow a
single Held By user to be added. We’d need to define a convention for
having multiple people in that single column, possibly doing it by
email address which is easily parseable with tools, but right now that
column only goes by username (or user id).

Try tweaking the code and definitely file a bug about this because it
feels like an accidental oversight.

-kevin


RT Training - Boston, September 9-10
http://bestpractical.com/training

Mitch Kyser
Network Administrator
Albion.College
mkyser@albion.edu

Thanks for the response. I took a look at /opt/rt4/local/plugins/
RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/[1]CSV.PM and
removed the check you suggested by commenting out lines 64 thru 67;

#if ( not RT::Asset->Role($fieldname)->{Single}) {

RT->Logger->warning( "Role name $fieldname must be single-value for

“._column($field2csv->{$fieldname}).”, skipping");

delete $field2csv->{$fieldname};

#}

Instead of the single warning I got one for each asset I tried to update that
had a username to be placed in the HeldBy field;

[error]: Failed to set HeldBy to mkyser for row 5408: No valid Type specified
(/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/
Import/CSV.pm:178)

When I tried using ‘Owner’ instead of ‘HeldBy’ I got the same results.

Try applying the change from the attached patch

I will see what it takes to submit a bug report like you suggested, then submit
one.

I moved your bug report into the assets queue (rather than the general
RT queue).

I am seeing similar things when I try to use the Bulk Update feature with
HeldBy, no error message but no change in HeldBy either.

This should be a separate bug report.

-kevin

csv.patch (729 Bytes)

After taking a little while to figure out just what the patch was (I’ve
never programmed in PERL before) I applied it to the CSV.pm along with the
lines I commented out above and I was able to use the import to populate
the HeldBy role from my csv file. There were a few exceptions and any
asset that already had a HeldBy entry did not get updated. Thanks, that
will get me by for now.

As for the issue with the Bulk Update, I was poking around and saw that
somebody else had already sent in a bug report for it.On Wed, Sep 17, 2014 at 4:03 PM, Kevin Falcone falcone@bestpractical.com wrote:

On Wed, Sep 17, 2014 at 02:27:57PM -0400, Mitch Kyser wrote:

Thanks for the response. I took a look at /opt/rt4/local/plugins/
RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/Import/[1]CSV.PM
and
removed the check you suggested by commenting out lines 64 thru 67;

#if ( not RT::Asset->Role($fieldname)->{Single}) {

RT->Logger->warning( "Role name $fieldname must be single-value for

“._column($field2csv->{$fieldname}).”, skipping");

delete $field2csv->{$fieldname};

#}

Instead of the single warning I got one for each asset I tried to update
that
had a username to be placed in the HeldBy field;

[error]: Failed to set HeldBy to mkyser for row 5408: No valid Type
specified

(/opt/rt4/local/plugins/RT-Extension-Assets-Import-CSV/lib/RT/Extension/Assets/

Import/CSV.pm:178)

When I tried using ‘Owner’ instead of ‘HeldBy’ I got the same results.

Try applying the change from the attached patch

I will see what it takes to submit a bug report like you suggested, then
submit
one.

I moved your bug report into the assets queue (rather than the general
RT queue).

I am seeing similar things when I try to use the Bulk Update feature with
HeldBy, no error message but no change in HeldBy either.

This should be a separate bug report.

-kevin


RT Training - Boston, September 9-10
http://bestpractical.com/training

Mitch Kyser
Network Administrator
Albion.College
mkyser@albion.edu

role from my csv file. There were a few exceptions and any asset that already
had a HeldBy entry did not get updated. Thanks, that will get me by for now.

It should only be skipping this if the same user is specified as
HeldBy. You’re seeing this even if it’s a different user?

As for the issue with the Bulk Update, I was poking around and saw that
somebody else had already sent in a bug report for it.

Great.

-kevin

Ok, after double checking my csv file and running a few more tests;

If there is no user in the HeldBy field then the import will add the user
in the csv file.

If the user in the csv file is different from the user already in HeldBy
then the import will add the user so you end up with multiple users in the
HeldBy field.

If the csv user is the same as the user already in HeldBy then no change is
made.

ThanksOn Thu, Sep 18, 2014 at 11:21 AM, Kevin Falcone falcone@bestpractical.com wrote:

On Thu, Sep 18, 2014 at 10:09:52AM -0400, Mitch Kyser wrote:

role from my csv file. There were a few exceptions and any asset that
already
had a HeldBy entry did not get updated. Thanks, that will get me by for
now.

It should only be skipping this if the same user is specified as
HeldBy. You’re seeing this even if it’s a different user?

As for the issue with the Bulk Update, I was poking around and saw that
somebody else had already sent in a bug report for it.

Great.

-kevin


RT Training November 4 & 5 Los Angeles
http://bestpractical.com/training

Mitch Kyser
Network Administrator
Albion.College
mkyser@albion.edu

Ok, after double checking my csv file and running a few more tests;

If there is no user in the HeldBy field then the import will add the user in
the csv file.

If the user in the csv file is different from the user already in HeldBy then
the import will add the user so you end up with multiple users in the HeldBy
field.

If the csv user is the same as the user already in HeldBy then no change is
made.

These all sound correct to me, and agree with what I saw of the intent
in the code.

Held By is a multi-value field, so it just adds more people to it.
Something like Owner is a single value field, so it would just be
replaced.

We need to expand the format to allow you to specify that there are
two Held By users in a single import, that’s not currently supported,
but it sounds like for now at least, the two changes made could be
released as a new version of the importer.

I’ll see if I can get to that next week.

I’m unlikely to have time to tackle “how to support importing multiple
people from a single field” as part of this release.

-kevin

This worked for be also (the patch and the line commenting), but somehow
between tries i got lots of assets with the user “nobody in particular” and
i can’t use the bulk update to remove it, since it doesn’t recognize that
user in the first place.

Is there an easy way to do this? I would rather have the asset with blank
than with nobody.

View this message in context: http://requesttracker.8502.n7.nabble.com/Assigning-HeldBy-users-during-Asset-Import-tp58502p58788.html