How is document template language versions handled in DB, and how to set using crmscript?
Hi all.
Just wondering - how is language versions handled for Document templates?
When addin a new language-version I cant see any changes in the DocTmpl-table. Looking the DocTmpl-table up, I can't find anything language-ish mentioned, and haven't had any luck finding any tables where this many-to-many relation would be stored.
Furthermore, how do you create a document in crmscript with a specific language?
When I lookup NSDocumentTemplatei I don't see any language-related attributes.
Allt Svar (12)
Document template languages aren't stored in the database anywhere, they are determined based on the subfolders in the SO_ARC template archive folder.
Ah yes, when generating a document you can pass the uiCulture to the CreateNewPhysicalDocumentFromTemplate method(s), but that seems to be ignored when generating a document from CRMScript. I guess/assume that the uiCulture also is used when determing which template language variant is used.
See bug registration: https://community.superoffice.com/en/product-releases/bugs-wishes/product-issue/?bid=37238&azure=1
To make things more spicy, I'm searching for a way to generate the pdf generated from a quote.
In the GUI (when pressing Send from a quote-draft) ,it is possible to choose which language version you want to use. The quote-documents behind the pdf that is generated is stored in the Document Template table. I guess your method of using NSDocumentAgent.GenerateNewPhysicalDocumentFromTemplate(..) isn't the correct one in this example.
NSQuoteAgent.SendQuoteVersion(...) takes 'culture : String' as an input. But havent figured how this works yet.
In regards to the OP, the document templates must have multiple languages defined in the document template dialog.
Read the docs to learn how to add languages to a template.
In a CRMScript, assuming the document template Id is 4, if you run the following script do you get the same results?
NSListAgent la;
String[] languages = la.GetDocumentTemplateLanguages(4);
printLine(languages.buildString(","));
Results:
da,nl,en
We have an open support request regarding this and will update as soon as we have more info.
To answer your orginal question Kasper:
Integer documentTemplateId = 207;
// get a stream of your document template variant here, for example purposes we just take the existing NL variant
NSStream documentTemplateVariantContent = listAgent.GetDocumentTemplateStreamFromId(documentTemplateId, "nl");
// retrieve existing base document template entity for the plugin code
NSDocumentTemplateEntity documentTemplateEntity = listAgent.GetDocumentTemplateEntity(documentTemplateId);
// create new variant which copies the default one
listAgent.CreateDefaultDocumentTemplateLanguage(documentTemplateId, "fr");
// save our variant
listAgent.SaveDocumentTemplateStream(documentTemplateId, variant, "fr", documentTemplateEntity.GetLoadTemplateFromPlugin());