Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data injection csv Location #121

Closed
mingosss opened this issue Sep 5, 2018 · 8 comments
Closed

Data injection csv Location #121

mingosss opened this issue Sep 5, 2018 · 8 comments

Comments

@mingosss
Copy link

mingosss commented Sep 5, 2018

Hi
I can not map the location of the equipment, in the fields the location field does not appear
Thanks

@ghost
Copy link

ghost commented Sep 5, 2018

Hello same problem here ! I can't specify a location when I'm trying to import computers ...

@cedric-anne
Copy link
Contributor

Comment initialy done on #103.

Hi,

I just investigate and this issue is due to the way the mapping is built. Fields proposal are based on linkfield of item "search options".

This linkfield is used by GLPI to handle table joins when searching/reading items data, and is automatically set if not defined in "search options" definition (see https://github.com/glpi-project/glpi/blob/9.3/bugfixes/inc/search.class.php#L5860). Unless on specific cases, this linkfield will be the ID field of corresponding table.
On a computer, all fields related to location have same linkfield: address, postcode, latitude, longitude, completename, town, state, country.

Mapping field dropdown is built using this linkfield as an array key. As key value is unique, and as fields are assigned in a foreach loop , only last field is available (see: https://github.com/pluginsGLPI/datainjection/blob/develop/inc/injectiontype.class.php#L212). For location , longitude is the last assigned as it is the last declared in "search options" (see: https://github.com/glpi-project/glpi/blob/9.3/bugfixes/inc/location.class.php#L121).

Two solutions can fix this problem:

  1. Use id of search option instead of linkfield as key in mapping.
  2. Use table.field instead of linkfield as key in mapping.

In both case, it requires a lot of work to modify all the mapping management and the way it is used when injecting files.

Regards

@loicbenoit
Copy link

Proposal for workaround

In GLPI location class, move "completename" to end of array. I will open a ticket in GLPI project to discuss this.

Not a bug fix, but seems to work

It doesn't fix the bug, but makes it work with no observed side effect so far. The solutions proposed by Cedric-Anne seems to be the proper way to fix the issue permanently, but it will take more time.

@loicbenoit
Copy link

Official proposal for workaround in GLPI Location class:
glpi-project/glpi#4589

@mingosss
Copy link
Author

mingosss commented Sep 7, 2018

Thanks a lot this work for me

@cedric-anne
Copy link
Contributor

Hi,

I proposed a more reliable solution that would fix this problem globally without having to touch core of GLPI. See #122.

@loicbenoit, as you take some time to investigate the problem, ould you tell me what you think of this solution ?

Regards

@cedric-anne
Copy link
Contributor

#122 validated by @loicbenoit .

@abhishek-rajput-44
Copy link

abhishek-rajput-44 commented Jul 20, 2022

Hi, I have installed glpi v10.00 on my local machine using XAMPP. Also installed latest plugin generic object management (version 2.12.1) to create new assets object and data / file injection (version 2.11.2) to import data by csv file for created new object. For example i have created new asset object called "Television" and i am using csv file with two columns "Name", "Location" to import data for the same. data is inserted but location field is not reflected in the list view.

I have applied the given solutions mentioned above for location issue, but still not working. Can anyone help me to resolve this issue. Where do i have to make changes in file level to work this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants