IDocumentFactory ( IDocumentFactory (kernel-documentation-dev 29.3.0 API)) is said to provide creation functionality for IDocuments.
The .createDocument method requires the corresponding Document Model ID, which is known:
public IDocument createA12Document() {
IDocumentModelResolver modelResolver = new DocumentModelResolver();
DocumentServiceFactory docServFact = new DocumentServiceFactory(modelResolver);
IDocumentFactory docFact = docServFact.createDocumentFactory();
IDocument doc = docFact.createDocument("MinSt_input");
IFieldInstance fieldInstance = docFact.createFieldInstance("/MinSt1/NameStpfl", new int[]{1, 1});
fieldInstance.setValue("tester");
doc.addEntityInstance(fieldInstance);
return doc;
}
We attempt to create an A12 document programmatically, set values for its fieldInstances.
Now I wonder: how to persist that created document?
I cannot find any .save, .persist (or similar) method in the documentation.
I’d greatly appreciate a working minimal example for the programmatic creation of an A12 document and how it can be persisted. Even though my above approach seems to work for the creation itself, I’d also want learn the best practice approach of this.
Thanks,
Alex