Zum Hauptinhalt springen

Dexpro-Connector

Dieses Modul ermöglicht die Interaktion mit der Dexpro-API.

Dafür werden verschiedene Funktionen bereitgestellt:

Funktionen

exportDocument

Die Funktion exportDocument exportiert ein Dokument zu Dexpro für die Analyse und Verarbeitung.

Definition

function exportDocument(options: ExportDocumentOptions): number;

Parameter

Rückgabewert

Die ID des erstellten Dokuments in Dexpro.

Beispiel

context.enableModules();

const { exportDocument } = require("ou.sp.DexproConnector");

// Note: Error handling is omitted for brevity in this block.
const fileId = "oucINV_fi20250000000219";
const docFile = context.getFileById(fileId);
const reg = docFile.getRegisterByName("documents");
const doc = reg.getDocuments().first();
const filePath = doc.getAsPDF();

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
filePath,
batchClassId: 1,
documentClassId: 1,
externalId: fileId,
overwriteFields: [{ name: "recipient", value: "R0100" }],
fieldMapping: { recipient: "Company" },
};

try {
const id = exportDocument(options);
// do something with the id...
} catch (error) {
// handle error...
}

getDocument

Die Funktion getDocument ruft die Daten eines Dokuments von Dexpro ab.

Definition

function getDocument(options: GetDocumentOptions): DexproDocument;

Parameter

GetDocumentOptions

Rückgabewert

DexproDocument

Beispiel

context.enableModules();

const { getDocument } = require("ou.sp.DexproConnector");

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
externalId: "oucINV_fi20250000000219",
};

try {
const document = getDocument(options);
const status = document.workflowContext?.status;
// do something with the data...
} catch (error) {
// handle error...
}

getAttachmentsForDocument

Die Funktion getAttachmentsForDocument ruft Informationen zu den Anhängen eines Dokuments von Dexpro ab. Die Anhänge selbst können als base64-kodierte Strings optional in der Antwort inkludiert werden.

Definition

function getAttachmentsForDocument(options: GetAttachmentsForDocumentOptions): DexproDocumentAttachment[];

Parameter

GetAttachmentsForDocumentOptions

Rückgabewert

DexproDocumentAttachment

Beispiel

context.enableModules();

const { getAttachmentsForDocument } = require("ou.sp.DexproConnector");

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
id: 5,
};

try {
const attachments = getAttachmentsForDocument(options);
// do something with the data...
} catch (error) {
// handle error...
}

downloadAttachment

Die Funktion downloadAttachment lädt einen Anhang eines Dokuments von Dexpro herunter und speichert diesen im Zielverzeichnis.

Definition

function downloadAttachment(options: DownloadAttachmentOptions): void;

Parameter

DownloadAttachmentOptions

Beispiel

context.enableModules();

const { downloadAttachment } = require("ou.sp.DexproConnector");

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
id: 5,
attachmentId: "some-attachment-id",
filePath: "/path/to/tmp/some-name.pdf",
};

try {
downloadAttachment(options);
} catch (error) {
// handle error...
}

addRowsToMasterDataTable

Die Funktion addRowsToMasterDataTable fügt Zeilen zu einer Stammdatentabelle in Dexpro hinzu.

Definition

function addRowsToMasterDataTable(options: AddRowsToMasterDataTableOptions): AddRowsToMasterDataTableResultItem[];

Parameter

AddRowsToMasterDataTableOptions

Rückgabewert

AddRowsToMasterDataTableResultItem[]

Beispiel

context.enableModules();

const { addRowsToMasterDataTable } = require("ou.sp.DexproConnector");

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
tableId: 10,
clear: true,
rows: [
{
externalid: 12,
CompanyId: "R0100",
CreditorId: "V2000001",
Name1: "Menking Lasertech GmbH",
// ...
},
// ...
]
};

try {
const result = addRowsToMasterDataTable(options);
const failedBatches = result.filter(item => item.error);
if (failedBatches.length > 0) {
throw new Error(`${failedBatches.length} batches failed.`);
}
} catch (error) {
// handle error...
}

updateMasterDataTableRows

Die Funktion addRowsToMasterDataTable aktualisiert Zeilen in einer Stammdatentabelle in Dexpro.

Definition

function updateMasterDataTableRows(options: UpdateMasterDataTableRowsOptions): UpdateMasterDataTableRowsResultItem[];

Parameter

UpdateMasterDataTableRowsOptions

Rückgabewert

UpdateMasterDataTableRowsResultItem[]

Beispiel

context.enableModules();

const { updateMasterDataTableRows } = require("ou.sp.DexproConnector");

const options = {
connection: {
baseUrl: util.getEnvironment("DEXPRO_BASE_URL"),
apiKey: util.getEnvironment("DEXPRO_API_KEY"),
},
tableId: 10,
rows: [
{
id: 123,
cells: [
{ CompanyId: "R0100" },
{ CreditorId: "V2000001" },
{ Name1: "Menking Lasertech GmbH" },
// ...
],
},
// ...
]
};

try {
const result = updateMasterDataTableRows(options);
const failedRows = result.filter(item => item.error);
if (failedRows.length > 0) {
throw new Error(`${failedRows.length} rows failed.`);
}
} catch (error) {
// handle error...
}