snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Bulk Import Overwrites Model Notes Field

Open knorquist opened this issue 6 years ago • 10 comments

Please confirm you have done the following before posting your bug report:

Describe the bug When an asset is uploaded using the bulk import feature, the notes field of the asset overwrites the notes field of the model.

To Reproduce Steps to reproduce the behavior:

  1. Prep CSV for bulk import. Have the "Notes" field populated for at least one asset with a pre-existing model (that is, a model already in the system).
  2. Go through the normal flow for importing the CSV.
  3. Navigate to the model entry of an asset with notes.
  4. The "Notes" field has been overwritten with the asset's notes.

Expected behavior The model isn't affected at all when assets are uploaded.

Server (please complete the following information):

  • Snipe-IT Version 4.8.0 - build 4186
  • OS: Ubuntu 18.04
  • Web Server: Apache
  • PHP Version 7.2.24

Additional context We have some info in the "Notes" field for some models, e.g. "Placeholder model", so this getting overwritten is an issue for us.

knorquist avatar Feb 03 '20 20:02 knorquist

I'm having the exact same issue.

smd75jr avatar Feb 17 '20 17:02 smd75jr

Is this still relevant? We haven't heard from anyone in a bit. If so, please comment with any updates or additional detail. This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Don't take it personally, we just need to keep a handle on things. Thank you for your contributions!

stale[bot] avatar Apr 17 '20 18:04 stale[bot]

Yes, still relevant.

knorquist avatar Apr 20 '20 15:04 knorquist

Okay, it looks like this issue or feature request might still be important. We'll re-open it for now. Thank you for letting us know!

stale[bot] avatar Apr 20 '20 15:04 stale[bot]

I can confirm I also have the exact same issue, every time when I import the assets, the asset's notes value will overwrite to the Asset Model's notes value

I can also confirm, even if the imported model is a new asset model, when the importer create the new asset model, it will also copy the notes value of the last imported notes value of that model.

Snipe-IT 4.9.2 PHP 7.1.33 MySQL 5.6.47 IIS Web Server at Windows Server 2008 R2

tamws27 avatar May 18 '20 10:05 tamws27

I look at the code and found that during the Import, if we checked the "Update Existing Values?" checkbox before Import, the code will go on log the "Matching Model found, updating it." and then try to update the Asset Model

However I think that why we need to do this, since the asset model name and model number already match the database value? I if comment the below codes and do a quick hack, then the import can still successful without touching the existing Asset Model items.

app/Importer/ItemImporter.php: Line 198 if ($asset_model) { if (!$this->updating) { $this->log("A matching model already exists, returning it."); return $asset_model->id; } /* Why we need to update the asset model if found it $this->log("Matching Model found, updating it."); $item = $this->sanitizeItemForStoring($asset_model, $editingModel); $item['name'] = $asset_model_name; $item['model_number'] = $asset_modelNumber; $asset_model->update($item); $asset_model->save(); $this->log("Asset Model Updated"); */ return $asset_model->id; }

tamws27 avatar May 18 '20 11:05 tamws27

Is this still relevant? We haven't heard from anyone in a bit. If so, please comment with any updates or additional detail. This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Don't take it personally, we just need to keep a handle on things. Thank you for your contributions!

stale[bot] avatar Jul 18 '20 05:07 stale[bot]

This issue has been automatically closed because it has not had recent activity. If you believe this is still an issue, please confirm that this issue is still happening in the most recent version of Snipe-IT and reply to this thread to re-open it.

stale[bot] avatar Jul 25 '20 06:07 stale[bot]

Still an issue!

knorquist avatar Jul 28 '20 20:07 knorquist

I've noticed this issue also. When bulk updating assets it is adding the last notes field to the model even though the model already exists. It doesn't seem to matter if I have the "Update Existing Values?" checkbox ticked or not.

perryk avatar Mar 24 '22 13:03 perryk