...
This section describes the importing and exporting mechanism. Importing and exporting are both considered process runs. For more information on implementing process runs, go to Implement Process Run Definition.
Create Import Processes
To create an import process, you need to:
- Define the import process in the imports.xml metadata file.
- Create the template file defined in the imports.xml metadata file for the import process.
- Create a process class extending com.crm.process.CRMImportBean, responsible for parsing the file and processing its records and define this process in modules.xml metadata file.
1. Imports Metadata File
The import process must be defined in the imports.xml metadata file, as shown in the example below. The metadata file can be located under the <custom_project>/src/main/resources/metadata/ directory. Note that all of the information except importdescription must be defined in the file. The processes defined in this file will appear in the Imports page, under Foundation > Utilities and you can view their process run logs, download their template file and submit them through this page.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<importsconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/imports.xsd"> <imports> ... <import> <importname>Custom Import</importname> <importdescription>Custom Import in CRM.COM.</importdescription> <importprocess>CUSTOM_IMPORT</importprocess> <importmodule>CUSTOM</importmodule> <importtemplatefilepath>imports/customTemplateFile.csv</importtemplatefilepath> </import> ... </imports> </importsconfig> |
2. Template File
The template file will be used as an example for the file used by the import process and can be downloaded from the import data entry page. The file must be placed under the directory defined in the imports.xml metadata file, with the importtemplatefilepath tag.
3. Import Process class
A process class must be created for the import process, extending com.crm.process.CRMImportBean. Below, you can see the implementation of an example import process class. It is recommended to use the LogTextFile method to log the import process results for easier debugging of the process.
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8"?> <moduleconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/modules.xsd"> <modules> ... <module> <moduleid>CUSTOM</moduleid> <modulename>key_custom_import</modulename> <moduledescription>key_custom_import</moduledescription> ... <features> <feature> ... <commonprocesses/> <additionalprocesses> <process> <id>CUSTOM_IMPORT</id> <name>key_custom_import</name> <description>key_custom_import</description> <methods> <method> <ejbname>EXAMPLEImportBean</ejbname> <methodname>import</methodname> <scheduled>false</scheduled> </method> </methods> <batch>true</batch> <csrincluded>true</csrincluded> </process> ... </additionalprocesses> </feature> </features> <leftmenuoptions> <id>CUSTOM_IMPORT_MERCHANT</id> <id>CUSTOM_IMPORT_BIN</id> </leftmenuoptions> </module> ... </modules> </moduleconfig> |
Create Export Processes
To create an export process, you need to:
- Define the export process in the exports.xml metadata file.
- Create a process class extending com.crm.process.CRMExportBean, responsible for creating the export file.
1. Exports Metadata File
The export process must be defined in the exports.xml metadata file, as shown in the example below. The metadata file can be located under the <custom_project>/src/main/resources/metadata/ directory. Note that all of the information except exportdescription must be defined in the file. The processes defined in this file will appear in the Exports page, under Foundation > Utilities and you can view their process run logs and submit them through this page.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<exportsconfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/exports.xsd"> <exports> ... <export> <exportname>Custom Export</exportname> <exportdescription>Custom Export in CRM.COM.</exportdescription> <exportprocess>CUSTOM_EXPORT</exportprocess> <exportmodule>CUSTOM</exportmodule> </export> ... </exports> </exportsconfig> |
2. Export Process class
A process class must be created for the export process, extending com.crm.process.CRMExportBean. Below, you can see the implementation of an example export process class. It is recommended to use the LogTextFile method to log the export process results for easier debugging of the process.
...