Last date modified: 2025-Jun-17
Export job
The following page illustrates how to complete an export job for exporting native files from a folder.
On GitHub, you can find can comprehensive samples illustrating how to export native documents, images, objects, and productions. For additional code samples, see the Export API samples repository.
Create an export job configuration
The following code sample illustrates how to configure an export job.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Workspace ID.
int workspaceID = 1020245;
// View ID.
int viewID = 1042326;
// Folder ID.
int folderID = 1003697;
// Job related data
Guid jobID = Guid.NewGuid();
string? applicationName = "Export-Service-Sample-App";
string? correlationID = "Sample-Job";
// Export source settings
var sourceSettings = ExportSourceSettingsBuilder.Create()
.FromFolder(exportSourceArtifactID: folderID, viewID: viewID)
.WithCustomStartAtDocumentNumber(1)
.Build();
// Artifact settings
var artifactSettings = ExportArtifactSettingsBuilder.Create()
.WithDefaultFileNamePattern()
.WithoutApplyingFileNamePatternToImages()
.WithoutExportingImages()
.WithoutExportingFullText()
.ExportNative(settings => settings.WithNativePrecedenceArtifactIDs(new List<int> { -1 })) // Exports only native files
.WithoutExportingPdf()
.WithFieldArtifactIDs(new List<int> { 1003676, 1003667 }) // Fields to export
.WithoutExportingMultiChoicesAsNested()
.Build();
// Subdirectory settings
var subdirectorySettings = SubdirectorySettingsBuilder.Create()
.WithSubdirectoryStartNumber(1)
.WithMaxNumberOfFilesInDirectory(100)
.WithDefaultPrefixes()
.OverridePrefixDefaults(prefixes =>
{
prefixes.NativeSubdirectoryPrefix = "Native_";
})
.WithSubdirectoryDigitPadding(5)
.Build();
// Volume settings
var volumeSettings = VolumeSettingsBuilder.Create()
.WithVolumePrefix("VOL_FOLDER_")
.WithVolumeStartNumber(1)
.WithVolumeMaxSizeInMegabytes(100)
.WithVolumeDigitPadding(5)
.Build();
// Loadfile settings
var loadfileSettings = LoadFileSettingsBuilder.Create()
.WithoutExportingMsAccess()
.WithoutCustomCultureInfo()
.WithLoadFileFormat(LoadFileFormat.CSV)
.WithEncoding("UTF-8")
.WithImageLoadFileFormat(ImageLoadFileFormat.IPRO)
.WithPdfFileFormat(PdfLoadFileFormat.IPRO_FullText)
.WithDelimiterSettings(delimiters =>
delimiters.WithDefaultDelimiters())
.Build();
// Output settings
var outputSettings = ExportOutputSettingsBuilder.Create()
.WithoutArchiveCreation()
.WithDefaultFolderStructure()
.WithDefaultDestinationPath()
.WithSubdirectorySettings(subdirectorySettings)
.WithVolumeSettings(volumeSettings)
.WithLoadFileSettings(loadfileSettings)
.Build();
// Connect all settings in the Job builder
var jobSettings = ExportJobSettingsBuilder.Create()
.WithExportSourceSettings(sourceSettings)
.WithExportArtifactSettings(artifactSettings)
.WithExportOutputSettings(outputSettings)
.Build();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Workspace ID.
int workspaceID = 1020245;
// View ID.
int viewID = 1042326;
// Folder ID.
int folderID = 1003697;
// Job related data
Guid jobID = Guid.NewGuid();
string? applicationName = "Export-Service-Sample-App";
string? correlationID = "Sample-Job";
var sourceSettings = new ExportSourceSettings()
{
ArtifactTypeID = 10,
ExportSourceArtifactID = folderID,
ExportSourceType = ExportSourceType.Folder,
ViewID = viewID,
StartAtDocumentNumber = 1
};
var artifactSettings = new ExportArtifactSettings()
{
FileNamePattern = "{identifier}",
ApplyFileNamePatternToImages = false,
ExportFullText = false,
ExportImages = false,
ExportNative = true,
ExportPdf = false,
FieldArtifactIDs = new List<int>() { 1003676, 1003667 },
NativeFilesExportSettings = new NativeFilesExportSettings()
{
NativePrecedenceArtifactIDs = new List<int>() { -1 }
},
ExportMultiChoicesAsNested = false
};
var subdirectorySettings = new SubdirectorySettings()
{
SubdirectoryStartNumber = 1,
MaxNumberOfFilesInDirectory = 100,
FullTextSubdirectoryPrefix = String.Empty,
ImageSubdirectoryPrefix = String.Empty,
NativeSubdirectoryPrefix = "Native_",
PdfSubdirectoryPrefix = String.Empty,
SubdirectoryDigitPadding = 5
};
var volumeSettings = new VolumeSettings()
{
VolumePrefix = "VOL_FOLDER_",
VolumeStartNumber = 1,
VolumeMaxSizeInMegabytes = 100,
VolumeDigitPadding = 5
};
var loadfileSettings = new LoadFileSettings()
{
ExportMsAccess = false,
CultureInfo = "en-US",
LoadFileFormat = LoadFileFormat.CSV,
Encoding = "UTF-8",
ImageLoadFileFormat = ImageLoadFileFormat.IPRO,
PdfLoadFileFormat = PdfLoadFileFormat.IPRO_FullText,
DelimitersSettings = new DelimitersSettings()
{
MultiRecordDelimiter = (char)059,
NestedValueDelimiter = (char)092,
NewlineDelimiter = (char)174,
QuoteDelimiter = (char)254,
RecordDelimiter = (char)020
}
};
var outputSettings = new ExportOutputSettings()
{
CreateArchive = false,
SubdirectorySettings = subdirectorySettings,
LoadFileSettings = loadfileSettings,
VolumeSettings = volumeSettings
};
var jobSettings = new ExportJobSettings()
{
ExportArtifactSettings = artifactSettings,
ExportOutputSettings = outputSettings,
ExportSourceSettings = sourceSettings
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
"ExportSourceSettings": {
"ArtifactTypeID": 10,
"ExportSourceType": 2,
"ExportSourceArtifactID": 1003697,
"ViewID": 1042326,
"StartAtDocumentNumber": 1
},
"ExportArtifactSettings": {
"FileNamePattern": "{identifier}",
"ApplyFileNamePatternToImages": false,
"ExportNative": true,
"ExportPdf": false,
"ExportImages": false,
"ExportFullText": false,
"ExportMultiChoicesAsNested": false,
"ImageExportSettings": null,
"FullTextExportSettings": null,
"NativeFilesExportSettings": {
"NativePrecedenceArtifactIDs": [
-1
]
},
"FieldArtifactIDs": [
1003676,
1003667
]
},
"ExportOutputSettings": {
"LoadFileSettings": {
"LoadFileFormat": 1,
"ImageLoadFileFormat": 1,
"PdfLoadFileFormat": 2,
"Encoding": "UTF-8",
"DelimitersSettings": {
"NestedValueDelimiter": "\\",
"RecordDelimiter": "\u0014",
"QuoteDelimiter": "\u00FE",
"NewlineDelimiter": "\u00AE",
"MultiRecordDelimiter": ";"
},
"ExportMsAccess": false,
"CultureInfo": null
},
"VolumeSettings": {
"VolumePrefix": "VOL_FOLDER_",
"VolumeStartNumber": 1,
"VolumeMaxSizeInMegabytes": 100,
"VolumeDigitPadding": 5
},
"SubdirectorySettings": {
"SubdirectoryStartNumber": 1,
"MaxNumberOfFilesInDirectory": 100,
"ImageSubdirectoryPrefix": "",
"NativeSubdirectoryPrefix": "Native_",
"FullTextSubdirectoryPrefix": "",
"PdfSubdirectoryPrefix": "",
"SubdirectoryDigitPadding": 5
},
"CreateArchive": false,
"FolderStructure": 0,
"DestinationPath": null
}
}
Create an export job
The following code sample illustrates how to create an export job entity in particular workspace. Job is defined by its unique Id generated by user and provided in the request.
using Relativity.Export.V1.IExportJobManager jobManager = serviceFactory.CreateProxy<Relativity.Export.V1.IExportJobManager>();
var validationResult = await jobManager.CreateAsync(
workspaceID,
jobID,
jobSettings,
applicationName,
correlationID);
Start an export job
The following code sample illustrates how to start an export job which enables the process that schedules export data from workspace based on the configuration assigned in previous sample.
// Start export job
var startResponse = await jobManager.StartAsync(workspaceID, jobID);
// Check for errors that occured during job start
if (!string.IsNullOrEmpty(startResponse.ErrorMessage))
{
_logger.LogError($"<{startResponse.ErrorCode}> {startResponse.ErrorMessage}");
// ...
}
Check export job status
The following code sample illustrates how to check the status of the export job, it will indicate whenever it failed, was completed, or is still running.
do
{
var status = await jobManager.GetAsync(workspaceID, jobID);
Console.WriteLine($"Job status: {status.Value.JobStatus}");
} while (jobStatus?.Value.JobStatus is not ExportStatus.Completed
and not ExportStatus.CompletedWithErrors
and not ExportStatus.Failed
and not ExportStatus.Cancelled);
Export Job States
The following table describes the export job states.
| Value | State | Description |
|---|---|---|
| 0 | New | Export job created but not started yet. |
| 1 | Scheduled | Export job scheduled and waiting for an agent. |
| 2 | Running | Job executing, export of data is currently in progress. |
| 3 | Completed | Export job completed. All records processed without errors. |
| 4 | CompletedWithErrors | Export job completed with some errors. All records processed but one or more item level errors occurred. |
| 5 | Failed | Export job failed with a fatal error. Not all records were processed. |
| 6 | Cancelled | Job cancelled by user. |
| 7 | Transferring | Export from Relativity to Transfer Service location completed. The transfer job is in progress, and export results are syncing to the destination location. |