Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

New QVW file on server not recognized by API

Hi All,

I have an application that uploads a qvw file to server (performs a windows file copy) and places it in a directory that qlikview server knows about for documents.  My problem is that when I try to retrieve that document via the API (m_QmsClient.GetUserDocuments(m_QvsGuid)), it is not in the list.  If I open QV Managment Console in a browser and select the documents tab, some sort of refresh happens.  Because when I run my code again, GetUserDocuments returns my new document.  At first I thought it was a timing issue, so I put a loop in my code and try again every 5 seconds.  It will sit there indefinitly until I browse to the Documents tab.  After that, the API knows about the new document.

I can't find anything on the API that will perform this step for me.  Has anyone seen this before?  I need to get the document so I can set some metadata for it (create a couple document attributes).

I am running QVS11 SR2.  I saw the same behavior in SR1 also.

Thanks,

Bob

1 Solution

Accepted Solutions
Not applicable
Author

Maybe try:

m_QmsClient.ClearQVSCache(QVSCacheObjects.UserDocumentList);

before you call GetUserDocuments?

Thinking about it, calling:

m_QmsClient.ClearQVSCache(QVSCacheObjects.UserDocumentMetaData);

might generate the default metadata for the new documents automatically - I'm not sure though.

Hopefully one/both of these will do the trick!

Michael

View solution in original post

5 Replies
Not applicable
Author

Hi Bob,

You could try something similar to the following (C#):

var documentMetaData = new DocumentMetaData();

// assign properties to documentMetaData

m_QmsClient.SaveDocumentMetaData(documentMetaData);

The thing is, I'm not sure exactly what the management console sets as the metadata when you browse to the documents tab. You might want to copy a file, browse to that tab, grab the newly created DocumentMetaData object for that document, serialise it and see exactly which properties are needed as a minimum.

I imagine it's simply documentMetaData.UserDocument.FolderID (should be the same as the FolderID of the folder that it's in) and documentMetaData.UserDocument.Name (should be the same as the document's filename), but I'm not 100% sure on this.

Michael

Not applicable
Author

Michael, Thanks for your reply.

I've tried your suggestion, but it didn't appear to work (completely).  I tried to create a new DocumentMetaData object based on an existing one.  That code is pasted below.  While the SaveDocumentMetaData is successful, GetUserDocuments returns null when I try to retrieve the document again.

However, after the SaveDocumentMetaData I do see a .Meta file on the file system.  So I'm getting closer but QMS API doesn't seem to recognize the new metadata I created.

                    DocumentFolder documentFolder = m_QmsClient.GetUserDocumentFolders(m_QvsGuid, DocumentFolderScope.Administrators)[0];

                    DocumentMetaData dmd = new DocumentMetaData();

                    dmd.QVSID = m_QvsGuid;

                    dmd.Scope = DocumentMetaDataScope.DocumentInfo;

                    dmd.UserDocument = new DocumentNode();

                    dmd.UserDocument.Type = DocumentType.User;

                    dmd.UserDocument.RelativePath = relativePath;

                    dmd.UserDocument.Name = documentName;

                    dmd.UserDocument.FolderID = documentFolder.ID;

                    dmd.UserDocument.ID = Guid.NewGuid();

                    DocumentMetaData.DocumentMetaDataDocumentInfo dmddi = new DocumentMetaData.DocumentMetaDataDocumentInfo();

                    dmddi.Attributes = new List<DocumentAttribute>();

                    dmd.DocumentInfo = dmddi;

                    m_QmsClient.SaveDocumentMetaData(dmd);

Not applicable
Author

Maybe try:

m_QmsClient.ClearQVSCache(QVSCacheObjects.UserDocumentList);

before you call GetUserDocuments?

Thinking about it, calling:

m_QmsClient.ClearQVSCache(QVSCacheObjects.UserDocumentMetaData);

might generate the default metadata for the new documents automatically - I'm not sure though.

Hopefully one/both of these will do the trick!

Michael

Not applicable
Author

Michael,

Thank you very much.  I searched QMSAPIDocumentation.chm and came across this comment in the Examples section.  So it appears clearing UserDocumentList does the trick.

// clear the QMS's QVS object cache from user document listings

            // so that the any new user documents can be discovered

            apiClient.ClearQVSCache(QVSCacheObjects.UserDocumentList);

Not applicable
Author

Glad to be of help!

Michael