Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

Document template could not be loaded from document plugin 0

Hi!
I want to add some documents to a sale using Netserver (SuperOffice.CRM.Services). The document entry is created but I get the following error when running CreateNewPhysicalDocumentFromTemplate to add the physical file.

SuperOffice.Exceptions.SoException
HResult=0x80131500
Message=Service call Document.CreateNewPhysicalDocumentFromTemplate failed with exception
Document.CreateNewPhysicalDocumentFromTemplate
Source=SuperOffice.Services.Implementation
StackTrace:
at SuperOffice.CRM.Services.Implementation.DocumentAgentLocal.CreateNewPhysicalDocumentFromTemplate(Int32 contactId, Int32 personId, Int32 appointmentId, Int32 documentId, Int32 saleId, Int32 selectionId, Int32 projectId, String uiCulture)
at SuperOffice.CRM.Services.DocumentAgent.CreateNewPhysicalDocumentFromTemplate(Int32 contactId, Int32 personId, Int32 appointmentId, Int32 documentId, Int32 saleId, Int32 selectionId, Int32 projectId, String uiCulture)
at ConsoleApp3.FSSuperOffice.AddDocument() in C:\Users\hansroger\Documents\Code\VS\ConsoleApp3\ConsoleApp3\FSSuperOffice.cs:line 86
at ConsoleApp3.Program.Main(String[] args) in C:\Users\hansroger\Documents\Code\VS\ConsoleApp3\ConsoleApp3\Program.cs:line 31

Inner Exception 1:
SoNotFoundException: Document template 'Innk. dokument' could not be loaded from document plugin 0.

 

 

My code:

ContactAgent ca = new ContactAgent();
Contact c = ca.GetContact(1);

SaleAgent saleAgent = new SaleAgent();
Sale sale = saleAgent.GetSale(50);


DocumentEntity document = new DocumentEntity
{
Contact = c,
Name = "Testdokument",
Description = "Test",
Sale = sale,
Attention = "ATT",
Header = "Test document",
OurRef = "Our",
YourRef = "Your",
Date = DateTime.Today
};

DocumentTemplate template = new DocumentTemplate
{
DocumentTemplateId = 28
};

document.DocumentTemplate = template;

DocumentAgent documentAgent = new DocumentAgent();
DocumentEntity savedDocument = documentAgent.SaveDocumentEntity(document);

Stream tempStream = new FileStream("C:\\Users\\hansroger\\Documents\\tilbud_16.docx", FileMode.Open, FileAccess.Read);
documentAgent.CreateNewPhysicalDocumentFromTemplate(c.ContactId, 0, 0, savedDocument.DocumentId, sale.SaleId, 0, 0, "nb-NO");

RE: Document template could not be loaded from document plugin 0

Not my domain but worth a try...
Your template is just a carrier and incomplete.
I think you need to get it from the ListAgent with GetDocumentTemlate( 28 );

/conrad

Af: Conrad Weyns 15. okt 2018

RE: Document template could not be loaded from document plugin 0

Thank you for your answer! Good point, now using ListAgent, still not working though.
What I'm trying to do is uploading a document to a customers sale.

I can do pretty much everything else throught the service, so I guess it's working.
My code:

DocumentAgent documentAgent = new DocumentAgent();
                DocumentEntity documentEntity = documentAgent.CreateDefaultDocumentEntity();
                documentEntity.Contact = contact;
                documentEntity.Sale = sale;
                documentEntity.Name = name;
                documentEntity.Header = name;
                documentEntity.Description = name;
                documentEntity.Person = person;
                documentEntity.Date = DateTime.Today;
                documentEntity.DocumentTemplate = listAgent.GetDocumentTemplate(6); //Incoming document template
                DocumentEntity savedDocumentEntity = documentAgent.SaveDocumentEntity(documentEntity);

                
                string uiCulture = SuperOffice.Globalization.ResourceManager.GetUICulture();
                documentAgent.CreateNewPhysicalDocumentFromTemplate(contact.ContactId, person.PersonId, 0, savedDocumentEntity.DocumentId, sale.SaleId, 0, 0, uiCulture);

                Stream tmpStream = new FileStream("C:\\temp\\Documentation.docx", FileMode.Open, FileAccess.Read);
                documentAgent.SetDocumentStream(savedDocumentEntity, tmpStream, true);
                tmpStream.Close();

SuperOffice.Exceptions.SoException
HResult=0x80131500
Message=Service call Document.CreateNewPhysicalDocumentFromTemplate failed with exception
Document.CreateNewPhysicalDocumentFromTemplate
Source=SuperOffice.Services.Implementation
StackTrace:
at SuperOffice.CRM.Services.Implementation.DocumentAgentLocal.CreateNewPhysicalDocumentFromTemplate(Int32 contactId, Int32 personId, Int32 appointmentId, Int32 documentId, Int32 saleId, Int32 selectionId, Int32 projectId, String uiCulture)
at SuperOffice.CRM.Services.DocumentAgent.CreateNewPhysicalDocumentFromTemplate(Int32 contactId, Int32 personId, Int32 appointmentId, Int32 documentId, Int32 saleId, Int32 selectionId, Int32 projectId, String uiCulture)
at FSPriskatalogSOConnector.FSSuperOffice.AddDocument(String name, Int32 contactid, Int32 personid, Int32 saleid) in C:\Users\hansroger\Documents\Code\VS\FSPriskatalogSOConnector\FSPriskatalogSOConnector\FSSuperOffice.cs:line 97
at FSPriskatalogSOConnector.Program.Main(String[] args) in C:\Users\hansroger\Documents\Code\VS\FSPriskatalogSOConnector\FSPriskatalogSOConnector\Program.cs:line 46

Inner Exception 1:
SoNotFoundException: Document template 'Innk. dokument' could not be loaded from document plugin 0.

 

Could I be missing some configuration details? Just using a pretty much standard app.config provided with the nuget package.

 

I would really appreciate if someone could point me in the right direction here.

Af: Hans Roger Lien 6. nov 2018

RE: Document template could not be loaded from document plugin 0

Hi Hans,

Have you set the Document settings in the config file? ArchivePath, TempPath, etc....

https://community.superoffice.com/en/content/content/netserver-sdk/netserver-3x/NetServer-Web-Services-Document-Management/

Do you have the templates installed there?

Af: Tony Yates 6. nov 2018

RE: Document template could not be loaded from document plugin 0

Hi Tony!
Yeah I just realized when i hit the post button that my so_arc pointed to my local machine. Guess what i found inside that folder... yeah, my testdocuments... With the right path and impersonation, it now works like å charm! :-)

Thanks again for your quick responses!

Af: Hans Roger Lien 6. nov 2018