Skip to content

Mapping extractions from to DocuWare#

The process of mapping our extraction results can be quite technical as it requires mapping our results to specific tabular structures in DocuWare, which in and of itself requires knowing and using the database structures DocuWare uses to store data.

We'll use the same extraction structure used in the walkthrough to detail how these values need to be translated such that DocuWare can understand and ingest the data.

Inferred extraction format

JSON Aggregation to translate structures to DocuWare structures#

One of the most useful elements of the Invoice Extraction workflow is the parsing and collection of invoice line_items. Processing these, though, can be a bit of hassle as we wouldn't want to iterate over each of these fields and plug its value into a field on the DocuWare side. In addition, it typically makes sense to represent this data as a single Table field in DocuWare. To accomplish, though, we'll need to map elements from the extraction to a form that matches the Table structure of the DocuWare form.

Adding the Table field to the DocuWare dialog#

Before making any updates to the scenario, we'll need to add the Table field to the dialog which will accept the incoming line_items data. This can be done by creating a new Database field in your target DocuWare File Cabinet; these database field names that are displayed are particularly important to take note of as they are key names of the fields in our JSON structure that we'll later be generating.

Create a Positionen field

Afterwards, add this field to which ever DocuWare Dialog you'll use when uploading your document.

Iterating and Aggregation#

We use a JSON Aggregator and Iterator in combination, the iterator takes the array structure from the extractions and allows the workflow to process each element as a single instance. The aggregator then lets us combine each of these instances into a single collection-like structure again, while also allowing us to apply a structure to each element; in this case that structure being a JSON object that DocuWare can understand.

Iterator to aggregator

It's important to note that, whichever module is selected as source, all data produced between that source module and this aggregation module is inaccessible. To ensure we still have access to all data produces earlier in the scenario, we reference the Iterator as the source here.

Iterator to aggregator

Define a Data Model for the transformation#

The Data Model used during the aggregation step is what will generate the objects which DocuWare will understand. As mentioned earlier, the database field names are used as the name (aka key) of each of the fields we define in the specification. An additional aspect to keep under consideration, is ensuring the typing information matches: 1) what is produced in our extraction, 2) what DocuWare expects as the field type when populating the fields of your form. If the typing information does not match what is expected either the scenario will fail or DocuWare will return a typing issue.

Mapping the extraction to dialog columns Mapping the extraction to dialog columns

Pass data from module to DocuWare#

As we've shown in the tutorial, the JSON string we produce during the aggregation phase can be used directly in the Positionen field of our DocuWare dialog. In the tutorial we used the Store to File Cabinet action of the DocuWare module to allow the extracted line_items to be attached as part of the invoice document being uploaded. We'll use a Store To File Cabinet module as it supports the mapping of the JSON string we just created to our Positionen Table field.

Technically, the other store actions indicate they also support providing JSON strings as the value of a Table field, however during our testing this feature was not functional in the other store actions.

Note: it is not advised to make any fields which may be mapped to an extraction field required. Since the data extracted is transient and may not always be present in every extraction, your workflow may break if you make such fields required.