KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically Import/Export Data with Settings
PRODUCT: 4D | VERSION: 13.1 | PLATFORM: Mac & Win
Published On: September 28, 2012

4D's EXPORT DATA and IMPORT DATA commands have an optional project parameter. This parameter allows developers to import/export data with given settings. Using the project parameter will bypass the import/export dialog if the other optional * parameter is not is not specified.

A 4D settings file (*.4si) can be saved and loaded into the project parameter using the command DOM Parse XML source. The 4D settings file can initially be created via the Export or Import window as shown below.



Once the settings file has been saved, data can be exported using the saved settings as follows:

$xmlStructRef_t:=DOM Parse XML source($pathToSettingsFile_t)
EXPORT DATA($exportFile;$xmlStructRef_t)
DOM CLOSE XML($xmlStructRef_t)

The variable $pathToSettingsFile_t is a text variable containing the path to the settings file.

The data can then be imported into another database using the following code:
$xmlStructRef:=DOM Parse XML source($pathToSettingsFile_t)
IMPORT DATA($exportFile;$xmlStructRef)
DOM CLOSE XML($xmlStructRef)