activityinfo-R icon indicating copy to clipboard operation
activityinfo-R copied to clipboard

importRecords does not match on form label/key field label when importing references

Open jamiewhths opened this issue 1 year ago • 3 comments

When using importRecords in the R package, the matching algorithm requires the user to always provide the reference field label. This is problematic as when users export a form with a reference field from ActivityInfo, the export will "unroll" the reference field using the key fields defined on each form, and use the reference form label concatenated with key field label for column headers. Unfortunately this means that users will often not be able to use the export CSV/XLSX from ActivityInfo as a template for import via the R package, which is a poor user experience.

Take the following form design:

  • Registry
    • Name: Text
    • Location of registrant: Reference [City]
  • City
    • Name: Text (KEY)
    • Country: Reference [Country]
  • Country
    • Name: Text (KEY)

The table view/exporter will take the key fields from the referenced form and export the following headers:

  • Name
  • City Name
  • Country Name

And the (manual) importer will match the columns accordingly:

  • Name => Name
  • City Name => [Location of registrant].Name
  • Country Name => [Location of registrant].Country.Name

The R package should follow a similar matching algorithm to allow easy reuse of the exported column format.

CC: @Ryo-N7

jamiewhths avatar Jul 18 '24 11:07 jamiewhths

Does the importer match reference keys at all? I believe it only accepts the record id of the refernced record. The importRecords function could be extended, but we will end up more and more with two parallel implementations of a complex operation. For example, the importRecords function doesnt do any validation at all. Let's review this on the context of the api importer project and see if we can expose the importer machine in all its glory to the API

On Thu, Jul 18, 2024, 1:14 PM Jamie Whitehouse @.***> wrote:

When using importRecords in the R package, the matching algorithm requires the user to always provide the reference field label. This is problematic as when users export a form with a reference field from ActivityInfo, the export will "unroll" the reference field using the key fields defined on each form, and use the reference form label concatenated with key field label for column headers. Unfortunately this means that users will often not be able to use the export CSV/XLSX from ActivityInfo as a template for import via the R package, which is a poor user experience.

Take the following form design:

  • Registry
    • Name: Text
    • Location of registrant: Reference [City]
  • City
    • Name: Text (KEY)
    • Country: Reference [Country]
  • Country
    • Name: Text (KEY)

The table view/exporter will take the key fields from the referenced form and export the following headers:

  • Name
  • City Name
  • Country Name

And the (manual) importer will match the columns accordingly:

  • Name => Name
  • City Name => [Location of registrant].Name
  • Country Name => [Location of registrant].Country.Name

The R package should follow a similar matching algorithm to allow easy reuse of the exported column format.

CC: @Ryo-N7 https://github.com/Ryo-N7

— Reply to this email directly, view it on GitHub https://github.com/bedatadriven/activityinfo-R/issues/129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADO5Q63U4I3JFHBYGJ63LLZM6PRDAVCNFSM6AAAAABLCOM3SWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQYTMMBZGE2DONQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

akbertram avatar Jul 18 '24 12:07 akbertram

@Ryo-N7 for your import via importRecords, you will need to import your records with the reference record id and using the reference field label rather than the key fields in your current import file.

jamiewhths avatar Jul 18 '24 12:07 jamiewhths

Can we close this?

nickdickinson avatar Oct 16 '24 08:10 nickdickinson