Skip to main content
Version: Next

Export structure file

Export structure file ( folderPath {; options} ) : Object

ParameterTypeDescription
folderPathTextPath of the destination folder for project files
optionsObjectExport options
Function resultObjectValidation status and messages (if any)

This command is not thread-safe, it cannot be used in preemptive code.

Description

The Export structure file command breaks down the current 4D database structure into a set of text-based files or native picture files and stores them in the specified folderPath. By default, the entirety of the database structure (methods, forms, catalog, etc.) is exported. You can filter the contents to export using the options parameter (see below).

This command allows you to store database structure files in a source control repository (i.e., Git, Perforce, etc.). Successive changes or changes from several sources can then be compared using standard source control tools.

This command can be used in the following contexts only:

  • 4D in local mode or 4D Server (an error is returned if it is called from 4D in remote mode),
  • Interpreted database (the command does nothing if it is called from a .4DC database)

Note also that when it is called from a component, the command always exports the host database structure.

In folderPath, pass the system path of the folder where the export files must be saved.

The options parameter allows you to customize the conversion process. The options object can contain the following properties:

Property nameValue typeDescription
withLogboolean or string
true or "always": create a conversion log file the destination Logs folder.
"ifNotEmpty": create a conversion log file only if it contains some messages
false or omitted (default): do not create a conversion log file
makeProjectbooleantrue to generate a .4DProject file in the "Project" folder
filterobjectContents to export. If omitted (default), everything is exported
projectMethodsbooleantrue to export project methods
databaseMethodsbooleantrue to export database methods
triggerMethodsbooleantrue to export trigger methods
formsbooleantrue to export forms
pageFormatbooleantrue to include the forms page format as "pageFormat" property of each form json file
catalogbooleantrue to export table and field definitions
foldersbooleantrue to export Explorer folders definitions
settingsbooleantrue to export structure settings
menusbooleantrue to export menus
tipsbooleantrue to export tips
listsbooleantrue to export lists
filtersbooleantrue to export filters
picturesbooleantrue to export pictures from picture library
resourcesbooleantrue to export Resources folder
trashbooleantrue to export trashed methods and forms (*)
windowPositionsbooleantrue to export window positions
methodPreferencesbooleantrue to export method editor preferences
buildSettingsbooleantrue to export the buildApp.xml file
dataPathbooleantrue to copy the last open data file path into the project user preferences file
directorybooleantrue to export 4D users and groups
styleSheetsbooleantrue to export style sheets as CSS
documentationbooleantrue to export Explorer comments as markdown files

(*) The "trash" filter is useful only if "projectMethods" or "forms" filters are also selected.

Warning: When the options parameter is passed and the "filter" object is used, you must explicitly declare each property to export with the true value. When this object is passed, 4D assumes all properties are set to false by default.

Result

The command returns an object providing the final status of the export as well as information on encountered issues or errors, if any. The following properties are returned:

Property nameValue typeDescription
successbooleanTrue if export operation was successful, false otherwise.
messagescollectionCollection of objects describing issues encountered during the export operation
[ ].severitytextLevel of issue. Possible values: "info", "error". Only "error" level sets the "success" property to false.
[ ].messagetextDescription of the issue or error, for example "Unsupported for object type"
[ ].errorscollectionError stack (if any)

Note: Issue objects can include additional properties depending on the context.

Possible errors include:

  • duplicated elements
  • file management errors (file already exists, file locked, disk full, etc.)
  • unsupported form object or property (see also ).

Example 1

You want to export the database structure file in an "Export" folder with the default settings:

 var $result : Object
 $result:=Export structure file("Export")
 If($result.success=True)
    ALERT("Export successful")
 Else
    ALERT("Error during export")
 End if

Example 2

You want to export only project and database methods, and a log file:

 var $option;$result : Object
 $option:=New object("filter";New object)
 $option.filter.projectMethods:=True
 $option.filter.databaseMethods:=True
 $option.withLog:="always"
 $result:=Export structure file("exportWithLog";$option)

See also

FORM Convert to dynamic