Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

amien
Valued Contributor

QVS API Support

my bad .. your right

Not applicable

QVS API Support

Stephan,

I`ve tried that out, but GetDocumentMetaData requires a DocumentNode, and i cant figure out how to get that from a Document Path.

I found a method GetUserDocuments, but i dont want to iterate every document to find the according one, do you have any other ideas?

Also, then how would i Add an authorization Entry to the Document Meta Data?

Thanks!

Pablo

amien
Valued Contributor

QVS API Support

check my example Pablo

Employee
Employee

QVS API Support

Amien; your example does not show how to select one document. Also it handles user CALs, and not Document Authorization, that Pablo is asking for. =)

Pablo; it depends on how your folder structure is on the server, I would say. If you have only one folder (root) you could just use something like this;

List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);
DocumentFolder Folder = DocFolders[0];



If you need to "pick" one item based on the objects in the List<>, you can do like this;

List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);
DocumentFolder Folder = DocFolders.Find(xxx => xxx.General.Path=="");

I hope that explains it somewhat.



Not applicable

QVS API Support

Hi Stephan,

I get what you say, and that will help, but i still cant understand how to get the DocumentNode, that is what i will need in order to be able to SetMetaData (it requires the document node as a parameter).

With that final help, i think everything else i can work it out.

Thanks!

Pablo

Highlighted
Employee
Employee

QVS API Support

Use the GetUserDocumentNodes function. Smiley Happy

Not applicable

QVS API Support

Here's my code. Maybe it'll help:

// Get an instance of the API

QMSBackendClient apiClient = new QMSBackendClient();



// Get a time limited service key
ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();



// Get an instance of the services on the Qlikview server
List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);



// Get the document node of the 1 document you want it for
DocumentNode theDoc = apiClient.GetUserDocuments(qvsServices[0].ID).Single(x => x.Name == "The name of the doc you want");



// Get the document's metadata using the node
DocumentMetaData theDocMetaData = apiClient.GetDocumentMetaData(theDoc, DocumentMetaDataScope.All);



// Do what you need to with the document meta data





Employee
Employee

QVS API Support

Here's an example of how to extract meta data for a document (Films) in the root folder, add an access post for a user, and save it back:

//*** Get user document folders
List<DocumentFolder> DocFolders = BackendClient.GetUserDocumentFolders(QvsGuid, DocumentFolderScope.All);

//*** Get root folder (either way)
//DocumentFolder Folder = DocFolders.Find(it => it.General.Path=="");
DocumentFolder Folder = DocFolders[0];

//*** Get document nodes with Folder ID
List<DocumentNode> Documents = BackendClient.GetUserDocumentNodes(Folder.ID, "");

//*** Get document meta data for specific document, only authorization scope
DocumentMetaData DocMetaData = BackendClient.GetDocumentMetaData(Documents.Find(it => it.Name == "Films.qvw"), DocumentMetaDataScope.Authorization);

//*** Add new access - make sure to populate the week list (cannot be null)
DocMetaData.Authorization.Access.Add(new DocumentAccessEntry { UserName = "domain\user1", DayOfWeekConstraints = new List<DayOfWeek>() });

//*** Save
BackendClient.SaveDocumentMetaData(DocMetaData);



Not applicable

QVS API Support

Stephan and herman, Thanks a lot for both your help!

I will go one with your codes to develope everything i need.

Thanks a lot!

Pablo

Not applicable

QVS API Support

Stephan,

Are you sure the method Add exist withing the Access methof of authorization?

DocMetaData.Authorization.Access.Add(new DocumentAccessEntry { UserName = "domain\user1"

I get an error message saying that System.Array does not contains a definition for Add.

thanks and sorry to continue bothering with this!

PAblo

Community Browser