Closed proweb01 closed 7 years ago
I have the same problem with importing device to users. For me it seems to only import to local users and not ldap users. Need some more testing to verify this.
About the problem with not showing all assets, check if you have a search filter (it remembers it).
Check the status label they are associated with, and make sure it's a deployable status type.
I have tested with several status types, and without a status. I have been testing this for some hours now with alot of imports.
The importer.log file always says this, so not sure how to use it: [2016-10-26 22:53:46] production.INFO: Status: Ready to Deploy [2016-10-26 22:53:46] production.INFO: No user data provided - skipping user creation, just adding asset [2016-10-26 22:53:46] production.INFO: --- User Data --- [2016-10-26 22:53:46] production.INFO: Full Name: [2016-10-26 22:53:46] production.INFO: First Name: [2016-10-26 22:53:46] production.INFO: Last Name: [2016-10-26 22:53:46] production.INFO: Username: gaa [2016-10-26 22:53:46] production.INFO: Email: [2016-10-26 22:53:46] production.INFO: --- End User Data --- [2016-10-26 22:53:46] production.INFO: User gaa already exists
It is a random user that get most of the importes assets, if I delete that user and reimport another random user get the assets.
Anyone have any suggestions?
+1 on the comment above. After trying every possible combination of user/no user/asset type/etc I ended up just importing all the assets without a user and assigning assets/accessories one by one (which is taking forever with 300ish users and hundreds more assets and licenses).
@bjorntk can you grab the latest from the master branch and see if that helps? Also, can you include (in a text file attachment) a sample of the data thats not importing? (You can change the serial, etc to mask private info). I'm unable to reproduce this, so seeing the data would be really helpful. (You can also PM it to me in the Gitter channel if you prefer.)
I found it!
It selects the next user (ID) with no email adress set as the owner of the assets.
I checked the database and the user that got the assets assigned did not have a email adress. I then deleted that user, and the next with no email adress got the assets after the import.
To verify I deleted all users without email adresses, and now it is working fine.
Feature or bug? :)
I tested the above and got the exact same results. Unfortunately for me, deleting all of the users without an email address isn't really an option. And, every time we sync from AD, those users we deleted will probably resync and leave us in the same boat again.
I only deleted the users as a test. Hoping there will be a fix for this. Or else I will have to enter fake mail adresses as a workaround.
What do you have set for Email Format in Admin > Settings?
(My guess is that there was no option selected for that - might want to check the DB table to confirm that.)
It was already set to "first name last name", I just tried changing it. And also changing other mail settings with no luck.
Version v3.5.1-2-gd7222ae
Thanks for your effort trying to help with this.
Can you tell me what the settings
table has for email_format
and username_format
? I keep trying to reproduce this, even with users without an email address, and I can't :(
This is from my settings:
email_format: firstname.lastname
username_format: filastname
The error only happens if the user with no e-mail is imported with ldap, if the user is local it works fine. The ldap is AD, not sure if that matters.
Another note, the actual usernames imported do not fit the pattern in the username_format (as there is several patterns: examples: 3-6 letters, 2 letters and 5 numbers.)
I will try to debug some here, but not sure what to look for.
Here is what I have found so far.
Asset Tag,Category,Model Name,Manufacturer,Username,Status
PC111,Laptop,ThinkPad T450,LENOVO,hk13168,
insert into assets
(asset_tag
, _snipeit_mac_address
, _snipeit_imei
, _snipeit_sim
, _snipeit_nummer
, purchase_cost
, model_id
, assigned_to
, rtd_location_id
, user_id
, status_id
, supplier_id
, updated_at
, created_at
) values ('PC111', '', '', '', '', '0', '13', '8238', '', '1', '2', '2', '2016-10-29 21:32:31', '2016-10-29 21:32:31') (310μs)
8238 is the user without e-mail adress, the correct in this import would have been 8379.
I then put the e-mail adress back for 8238, but remove it for user 8502, and with a new import it correctly set 8379 as the user.
Not sure if my explanation is so good (don't use english so often anymore), but it looks like when importing to user it counts up and breaks off when there is no email, but if the user have a lower ID than the user without email it correctly sets the correct user.
Can I see your full CSV header?
That is the one I'm using when I test now. Is there something missing there? I have tried many combinations, but ended up with this.
Well I don't see Name (for user's name) or Username in there, so I'm trying to figure out how it's assigning anything to anyone.
Asset Tag,Category,Model Name,Manufacturer,Username,Status
PC111,Laptop,ThinkPad T450,LENOVO,hk13168,
Username is there almost at the end. In this case the username is hk13168
And what about their name name? (First name Last Name)
Jey, thanks!
That worked. I just used the info from: https://snipe-it-manual.readme.io/docs/importing-assets
Status - A status label applied to the item. Created if it doesn't exist. If you leave this blank and provide a username, it will automatically be checked out to that user. Name is not a Required field.
I did not catch that it was needed with both fields. Now I just have to get both name and username and I can start the imports.
Thanks for the good support. And sorry for not posting my CSV at first.
Ah, excellent - we'll try to make that importer a little less brittle. It's a constant work in progress, since it's one of the most complicated things in the system. (It does a lot, as you can tell.)
@proweb01 can you confirm whether this is also your issue?
I think that this is actually related to User::scopeMatchEmailOrUsername in User.php, which is how we try to lookup a user based on username.
The releveant code:
public function scopeMatchEmailOrUsername($query, $user_username, $user_email)
{
return $query->where('email', '=', $user_email)
->orWhere('username', '=', $user_username)
->orWhere('username', '=', $user_email);
}
Not sure why we try to match username against email, but it's existed for about a year now... since https://github.com/snipe/snipe-it/commit/71b85732.
Import option is working fine from csv file, but company_id and location_id is not working
Hey all,
Experiencing a strange issue... Here's what's happening. I have connected our Snipe-IT to LDAP and sync'd successfully. Great. Now, I have created a CSV which contains all of our laptops (I am just importing one category at a time to keep things simple). In the CSV, the Username is populated correctly with the owner of that device. On some of the devices, I set a different status and left the username blank. When I upload the CSV, the devices that had a blank username import as expected into "All Assets". However, only a few of the devices with the username populated actually get assigned properly to the owner (10, to be exact). The remaining 87 devices get assigned to a single random owner. It makes no sense at all.
Also (not sure if these are bugs or what), but there are two other things that seem to be issues. I would expect "All Assets" to actually show me all devices, regardless of status/owner, but it doesn't. It only shows me the 48 devices with no username. But, even though they do not show a user in the "Checked Out To" column, there is a Checkin button (which would indicate they actually ARE checked out.
I also imported some purchase dates in the CSV with a warranty period of 36... However, the "EOL" column displays the purchase date instead of an expect purchased date+36 months.
Any suggestions would be helpful.