Create/update a DocumentV2?

The Document V2 API described here looks promising: GetA12 Login

The docs describe how to create, read, update, serialize a document using V2.
What is never mentioned, though, is how to actually persist a created or updated document.

The only way I found so far looks like this:

    public DocumentV2 createDocument(DocumentV2 documentV2) {
        var documentV1V2Converter = documentServiceFactory.createDocumentV1V2Converter();
        var documentV1 = documentV1V2Converter.toDocumentV1(documentV2);
        var dataServicesDocument = documentService.create(documentV1, Locale.GERMANY);
        var documentId = dataServicesDocument.getMetadata().getDocRef().getDocumentId();
        var newDocumentV1 = dataServicesDocument.getKernelDocument();
        newDocumentV1.setId(documentId);
        return documentV1V2Converter.ofDocumentV1(newDocumentV1);
    }

Two questions:

  • Is there a way that avoids converting to and fro V1 documents?
  • Why the is the ID still empty after calling documentService.create()? (I have to set it manually.)

Moin @stephen-warm-graph,

Question 1
currently the other A12 components don’t integrate the DocumentV2 API yet.
Therefore, in Data Services persistence layer, you have to use IDocument from Document V1 API for all extension points.

At the moment there is no other alternative than using the DocumentV1V2Converter if you want to use the DocumentV2 API.

There is a workstream already, so the other A12 components also integrate and support DocumentV2. The plan so far is, to provide this in the 2025.06 release.

Question 2

I assume you mean the “id” of the IDocument instance. This is not set by Data Services, because they don’t use and rely on it. The document reference is present after the DocumentService#create.

You can access it by using it like this:

DataServicesDocument dataServicesDocument = documentService.create(documentToCreate, Locale.ENGLISH);
DocumentReference docRef = dataServicesDocument.getMetadata().getDocRef();

Kind regards,
Jan