Hi Perry,
If I understand correctly, you are trying to create a new record with a specific slug, by defining what you want the new slug to be in your CSV, using the qubitParentSlug column, and it's not working - is that right?
If so:
Unfortunately, the qubitParentSlug column cannot be used like that. It is only used to link an incoming description to an existing parent record via the slug - i.e., your second case:
There is no way to perfectly define in advance via the CSV what slug you want a record to have - partially because slugs MUST be unique in AtoM, so how should AtoM handle an incoming CSV row that has a duplicate slug, or a slug with illegal characters? I'm sure different users will want different outcomes when issues are encountered, which quickly leads to some feature bloat if we try to address them all.
Instead, AtoM allows you via the settings to determine how slugs will be automatically generated, and then gives you the option to manually edit a slug AFTER it has been generated based on your settings. But: let's start with the CSV columns first.
Hierarchical relationships in CSV imports
There are two ways to define hierarchical parent-child relationships in an AtoM description CSV template: the parentId column, and the quibitParentSlug column. They are used for different purposes.
parentId
- the parentId column is used when you want to make a description row the child of another NEW record contained in the same CSV - for example, if you are creating a new series in row 3 of your CSV, and then in rows 4 and 5 you want to add two new file-level descriptions that will be imported as children to the new series. In that case, you would add the legacyId value of the series in row 3 to the parentId column of your files in rows 4 and 5. So long as the parent is created FIRST in the csv (AtoM imports the CSV in the order of the rows, so parent records should be in a row "above" any children), this is used to manage parent-child relations when both parent and child are found in the CSV
- Docs: https://www.accesstomemory.org/docs/latest/user-manual/import-export/csv-import/#legacyid-and-parentid
- Example:
qubitParentSlug
- the qubitParentSlug column is only used when you are importing new records that you want to add as children to an existing description in AtoM. So in this case for example, perhaps I have already created my Series-level record via the user interface, and now I want to import a CSV of file-level descriptions a children of that existing Series. To do so, I will copy the slug (i.e. the permalink - the unique part of the URL when on the view page of the parent record) of my target Series parent, and I will add that to the qubitParentSlug column for every row I want to import as a child of that Series. Because slugs are unique in AtoM, as the import progresses AtoM will use the slug as a lookup and attach those rows to the series description instead of importing them as new top-level records.
- Docs: https://www.accesstomemory.org/docs/latest/user-manual/import-export/csv-import/#qubitparentslug
- Example:
General usage notes
- AtoM does not force you to add a legacyId value to every row of your CSV import, but it is good practice to do it anyway, for potential future updates. However, legacyId values are REQUIRED if you intend to use the parentId column, since the values you add in the parentId column are the legacyId values of the target parent description.
- You CAN use both qubitParentSlug and parentId in a single CSV import - for example, you can add 1 row that creates a new file using qubitParentSlug to link that file to an existing series in AtoM, and then in the next row, create a new item-level description that uses the parentId column to make the item a child of the new file in the row above it. However, note that you CANNOT use qubitParentSlug and parentId in a single row - i.e. in a single description. If you do add values to both columns in a single row, AtoM will ignore the parentId value and use the slug value instead.
- There is another introductory section in the docs that outlines the legacyId column, and explains in part its role in update imports - see: https://www.accesstomemory.org/docs/latest/user-manual/import-export/csv-import/#legacy-id-mapping-dealing-with-hierarchical-data-in-a-csv
- In addition to the documentation linked above, we also have some slides that outline CSV description import preparation. See: https://www.slideshare.net/accesstomemory/csv-import-in-atom
- AtoM also has a CSV validator that can be run before an import, which would have reported this issue. See: https://www.accesstomemory.org/docs/latest/user-manual/import-export/csv-validation/
- It's also possible for an administrator to turn on a setting so that validation is automatically run BEFORE any import via the user interface, and can prevent the import if errors are found. See: https://www.accesstomemory.org/docs/latest/user-manual/import-export/csv-validation/#csv-validator-import-settings
- Note that there are many valid reasons why a well-formed CSV might generate warnings (for example, if you are purposefully creating a new archival institution record as part of your import, AtoM's validator will warn you about that, even though you're doing it on purpose). These are there to make sure you know the consequences of the import. For this reason, I don't recommend setting it to strict (and failing imports that generate warnings), but rather using the permissive setting (which will halt imports that generate errors, but not warnings).
Slugs in AtoM
Next, I wanted to quickly mention a few things about slugs, and some of the settings options available to you. First, an overview of how slugs work by default in AtoM is available here:
So, by default in AtoM, slugs are unique, and will be generated based on the title of the description in a new installation using default settings. However, you can change those settings to use the identifier or reference code instead - see:
Additionally, as noted in the first link, AtoM will by default automatically sanitize the slug - lowercasing all letters, removing special characters, replacing spaces with dashes, and appending an incrementing number to any non-unique slug value. Meaning by default, an attempt to use Bears and Man as a slug value would be sanitized to: bears-and-man.
However, AtoM also has another setting that will make the options for slugs more permissive - see:
When this setting is enabled:
- Case will be preserved when generating slugs
- Accented UTF-8 characters will be preserved in the slug
- Special characters that are not reserved (such as , - _ ~ : = * @ ) will also be preserved in generated slugs
Meaning, if your incoming description was titled "Bears and Man" and you had enabled the permissive slug setting, the default slug derived from the title would now be:
Finally, AtoM also has a module that will allow you to customize your slug after the import, if the generated slug is not to your liking (for example, maybe you already have a Bears-and-Man slug from a different description, and don't like the auto-generated Bears-and-Man-1 slug for the new description), you can customize it within the availabe limitations for slugs using the Rename module:
There is also a command-line task that can be used to rename a slug, either one at a time, or bulk via a simple CSV:
I hope this helps you properly configure your import for success in the next round!
Cheers,