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);
Alles Antwoorden (3)
Hello Dennis,
I'm not sure why you would think you cant set the document.Name manually, as the plugin will take care of checking if that name already exists (?).
document.Name is actually what is used to determine file extension, so if you set it to something like `MyGreatDocument.docx`, and it will take `.docx` as the fileExtension.
Let me know if you still are having issues with this! :)
Have a SUPER day!
//Eivind
Thank you for answering Eivind!
So i tried setting the name:
Hi Tony, is this what you want to see?
It's a normal E-Mail template.