# Bulk importing files

## <span class="mw-headline" id="bkmrk-what-it-does-1">What it does</span>

This page describes how to setup the bulk-import codeunit, to import a lot of files at once and generate a separate record in an entity, for each file.

## <span class="mw-headline" id="bkmrk-first-setup-1">First setup</span>

First, setup an entity with at least two fields: A [text-field](https://docs.tsnocode.com/books/field-type-reference/page/text "FieldText") for the filename and a [document field](https://docs.tsnocode.com/books/field-type-reference/page/documents "FieldFiles") for the document.  
Second, create or edit the following 5 "Static content".

1. BulkImport.SagID, the SagID of the entity that is the target of the import
2. BulkImport.UserGroupID, The GroupID of the usergroup that is allowed to access the bulk-import system
3. BulkImport.FileTitleField, The systemname of the field where the name of the file should be stored
4. BulkImport.FileFieldID, The FieldID of the field where the uploaded document should be stored
5. BulkImport.StatusID, The StatusID that uploaded documents should have

Third, edit the url on the site and access *main?command=dk.tempusserva.codeunit.bulkimport.ImportPage*  
Fourth, upload the files.

Next step could be to index all the files, allowing the content of the files to be searched and queried, maybe through ChatGPT.

## <span class="mw-headline" id="bkmrk-how-to-invoke-1">How to invoke</span>

<span class="mw-headline">\[Steps to enable codeunit\]</span>

### <span class="mw-headline">Options</span>

<span class="mw-headline">\[Optional options, that can be set at runtime, eg. url-parameters\]</span>

## <span class="mw-headline" id="bkmrk-configuration-1">Configuration</span>

<span class="mw-headline">\[All possible configurations and where to edit them\]</span>

## <span class="mw-headline" id="bkmrk-developer-info-1">Developer info</span>

- <span class="mw-headline">Type: [CodeunitPagecontent](https://docs.tsnocode.com/books/codeunit-reference/chapter/pagecontent)</span>
- <span class="mw-headline">Security: \[eg. requires admin or session\]</span>
- <span class="mw-headline">Classpath: dk.tempusserva.codeunit.bulkimport.ImportPage</span>