# Export Jobs
# Table of Contents
# Overview
An export job exports a selection of ContactManager data on a schedule. A job has two parts:
- What is exported — a query stored on the job itself.
- Where it goes — one or more export target definitions: a file on disk, an e-mail, or the document management system.
Both the job and the target definition are maintained as lookup items in the CRM Configuration screen, so each has its own code and name.
# Export target definition
A target definition describes one destination. Its Target type decides which settings apply:
| Target type | What it does |
|---|---|
| FileSystem | Writes the result to a file in a directory on the ContactManager server |
| Sends the result by e-mail, as an attachment or as a table in the message body | |
| DMS | Stores the result in the document management system |
# FileSystem settings
| Setting | Description |
|---|---|
| ExportDirectory | Directory on the ContactManager server where the file is written |
| FileType | Excel, Csv (semicolon-separated) or CsvKomma (comma-separated) |
| FileEncoding | Default, ASCII, UTF8, UTF7, UTF32, Unicode, BigEndianUnicode |
| AppendTimestamp | Adds the date and time to the file name, so each run keeps its own file |
| RemoveFile | Removes a file left by a previous run before writing the new one |
# Email settings
| Setting | Description |
|---|---|
| EmailFrom | Sender address |
| EmailToFieldOrAddress | A fixed e-mail address, or the name of a column in the result that holds the address |
| EmailCCEmailAddress | Address in cc |
| Subject | Subject of the message |
| Message | Body text of the message |
| RecordsAsTableInBody | Puts the exported records in the message body as a table |
| RecordsNoAttachment | Sends no attachment (use together with the table in the body) |
# Export job
A job holds:
| Field | Description |
|---|---|
| Code / Name | Identify the job; both can be used in the URLs below |
| Query | The selection that is exported. Returns no rows and the run reports No records found |
| Target definitions | One or more target definitions by code, name or ID, separated by a comma |
| Scheduled times / days / weeks | When the job runs — see Scheduling |
| Last run | Set to the moment the job last completed without errors |
The query may use the parameter LastRunDateTime, which holds the moment of the previous
successful run (empty on the very first run). Use it to export only what changed since then.
Because the value is only updated after a successful run, a failed run does not skip records.
# Scheduling
A job runs when all three schedule conditions match the current moment. A condition that is left empty always matches.
# ScheduledTimes
Required. A comma-separated list of times of day (HH:mm or H:mm).
09:00, 12:30, 17:00
The scheduler checks the jobs at short intervals; a job fires when the current clock time is within 5 minutes of one of these times.
# ScheduledDays
The days of the week on which the job may run. Check one or more days; when no day is checked the job runs every day.
# ScheduledWeeks
A comma-separated list of week numbers. When empty, the job runs every week.
1, 3, 5, 7
# Testing a job
Run the job by hand to check its query and its output. Sending the result to the browser shows the records without touching the target definition, which makes it the safest first test. Several jobs can be named in one call, separated by a comma.
# URL Reference
Jobs are addressed by ID, code or name.
| URL | What it does |
|---|---|
https://<cm>/exportjob.aspx/html/<id or code or name> | Runs the query and shows the result in the browser. Nothing is written to the target definition. |
https://<cm>/exportjob.aspx/export/<id or code or name> | Runs the job for real: the result is delivered to every active target definition of the job. |