1

Topic: Importing attributes

The import routine is flexible and works great in most situations. It currently (as far as i can tell) will not deal with "multiple" attributes. Any attempt to assign a second input column results in "There are currently two or more drop-downs allocated to the same value.", which is the appropriate validation to apply for normal fields.


For fields with the "multiple" flag set it would be ideal to allow more than one column in the csv import be assigned to the same attribute.

I've taken a look at the code and see that there is some javascript being applied on selection that locates duplicate fields and displays the above message. It also prevents submission of the form. It seems that the solution would be for this code that detects the duplicates could be enhanced by checking whether the field in question is "multiple" before considering it to be an error.

Would such an enhancement be desirable?  I'd appreciate any suggestions about the best approach in modifying the code to achieve this.

Robin

Robin Jones
IT Manager: Species Conservation
Wildfowl & Wetlands Trust

2

Re: Importing attributes

Hi Robin
I agree - this would indeed be desirable. Looking at the code, the import code calls $model->getSubmittableFields to grab an array of all available fields and this array does not have any metadata about the field other than the caption. Rather than try to change this (which might break things elsewhere) I wonder if the import service needs another public method (search for get_import_fields in indicia_svc_import for the existing one) to return a list of the custom attributes with metadata. Then this could be called by import_helper.php and the attribute metadata saved in the JavaScript indiciaData object, and would therefore be available for your suggested change.
Hope that makes sense,
John

John van Breda
Biodiverse IT

3

Re: Importing attributes

Thanks John,

that all makes sense. I will give it a go.

Robin

Robin Jones
IT Manager: Species Conservation
Wildfowl & Wetlands Trust

4

Re: Importing attributes

Before trying to deal with getting the initial form to allow the reuse of the same multi attribute,  I thought I'd just check how the import routine would behave if allowed.
I did this by temporarily changing the test condition on line 294 of import_helper.php so that it will not detect multiples :

if (duplicateStore.length==0) 
to:
if (duplicateStore.length!=-999) {

I was able to import a record by selecting the same attribute for two different fields. Only the second was successfully stored.
This must be because the second value replaces the first when the final submission array is created.

Normally to set a multiple submission you would append [] to the name of the shared inputs.  However the selects are named after the field name in the csv import and so would not share the same name for appending the [].

I'm not quite sure what to follow up next so any advice would be very welcome.

Robin

Robin Jones
IT Manager: Species Conservation
Wildfowl & Wetlands Trust