Hi forum
I was trying to programmatically generate a document. My document is generated an all, with the correct content, and the template variables substituted and all, so so far so good. But for some reason the file attached to the document entity does not have an extension. The template in question is a somail template.
Is there something i'm missing? as far as i know, i'm not supposed to give the document a name manually, as it has to make sure a file with the same name does not already exist.
Problem is right now, that SuperOffice does not open the document correctly (Since it has no idea how to handle it, due to the missing file extension)
But when it is downloaded, and i add .eml at the end, the mail is able to open inside outlook with no issue.
//Get a default document entity: /api/v1/Document/default
const document = await fetchData(`/api/v1/Document/default`);
//
document.Person = {PersonId: activeRowValues.medlem.id};
document.DocumentTemplate = {
DocumentTemplateId: activeRowValues.skabelon.id //.somail template
};
document.Header = "Udpegning af medlem til udvalg";
//Post the document
///api/v1/Document
const documentResponse = await fetchData(`/api/v1/Document`, document, 'POST');
//POST Document/{id}/Content
const documentContent = await fetchData(`/api/v1/Document/${documentResponse.DocumentId}/Content`, {}, 'POST');
//Update the document entity with the data from the documentContent
const documentResponse2 = await fetchData(`/api/v1/Document/${documentResponse.DocumentId}`, documentContent, 'PUT');
//POST /api/EMail/GetMailLinkOpenUrl?documentId=3146231
const emailLink = await fetchData(`/clientapi/EMail/GetMailLinkOpenUrl?documentId=${documentResponse2.DocumentId}`, {}, 'POST');
//Navigate to the document
window.location.href = emailLink;
//SuperOffice.ClientCrossMessaging.openDocument(documentResponse2.DocumentId);
console.log("Document Response:", documentResponse2);