Skip to main content Skip to complementary content
Close announcements banner

GetUserDocumentFolders Method

Overloads

GetUserDocumentFolders(Guid, DocumentFolderScope)

Gets all user document folders for the QlikView Server with the specified ID.

GetUserDocumentFolders(Guid, DocumentFolderScope)

Gets all user document folders for the QlikView Server with the specified ID.

Declaration

      List<DocumentFolder> GetUserDocumentFolders(Guid qvsID, DocumentFolderScope scope)
    

Parameters

Type Name Description
System.Guid qvsID

The ID of the QlikView Server for which to retrieve user document folders.

DocumentFolderScope scope

The scope of the user document folders to retrieve.

Returns

Type Description
System.Collections.Generic.List<DocumentFolder>

All user document folders with the specified scope for the QlikView Server with the specified ID.

Remarks

Only user document folders that the caller have access to will be returned.

security

Requires membership of local group QlikView Management API and the role Document Folder Administrator.

Examples

The following code example uses the QMS API to retrieve a registered QlikView Server, all its user document folders and nodes. The GetUserDocumentNodes(Guid, Guid, String) method is called recursively to print sub folders and user documents as a tree structure. If anything goes wrong, it prints an error message.

The service key injection is assumed to be handled behind the scenes. For an example of how to inject the service key, see Samples.

    using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using QMSAPI;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // create a QMS API client
            IQMS apiClient = new QMSClient();

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

            // get a list of QVS services
            List<ServiceInfo> qvsServices = apiClient.GetServices(ServiceTypes.QlikViewServer);
            if (qvsServices.Count > 0)
            {
                // retrieve all user document folders for the first QVS in the list
                Console.WriteLine("The " + qvsServices[0].Name
                    + " contains has following user document file structure:" + Environment.NewLine);
                List<DocumentFolder> userDocumentsFolders = apiClient.GetUserDocumentFolders(qvsServices[0].ID,
                    DocumentFolderScope.General | DocumentFolderScope.Services);
                // loop through all user document folders
                foreach (DocumentFolder userDocumentFolder in userDocumentsFolders.OrderBy(x => x.General.Path))
                {
                    // print the names of all user document folders,
                    // prefix with [R] for root folder and [M] for mounts
                    string folderPrefix = (string.IsNullOrEmpty(userDocumentFolder.General.Path) ? "[R]" : "[M]");
                    string folderName = (string.IsNullOrEmpty(userDocumentFolder.General.Path)
                        ? qvsServices[0].Name : userDocumentFolder.General.Path);
                    Console.WriteLine(folderPrefix + " " + folderName);
                    // print all sub nodes of the current user document folder
                    PrintUserDocumentNodes(apiClient, userDocumentFolder, string.Empty, 1);
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An exception occurred: " + ex.Message);
        }
        // wait for user to press any key
        Console.ReadKey();
    }

    static void PrintUserDocumentNodes(IQMS apiClient, DocumentFolder userDocumentFolder,
        string relativePath, int indentationDepth)
    {
        // retrieve all user document nodes of the given folder and under the specified relative path
        List<DocumentNode> userDocumentNodes = apiClient.GetUserDocumentNodes(userDocumentFolder.Services.QVSID,
            userDocumentFolder.ID, relativePath);
        // loop through all current user document nodes
        foreach (DocumentNode userDocumentNode in userDocumentNodes
            .OrderByDescending(x => x.IsSubFolder).ThenBy(x => x.Name))
        {
            // print the names of all user document nodes, indent and
            // prefix with [F] for folders and [D] for documents
            string indentation = new string(' ', indentationDepth * 3);
            string nodePrefix = (userDocumentNode.IsSubFolder ? "[F]" : "[D]");
            Console.WriteLine(indentation + nodePrefix + " " + userDocumentNode.Name);
            // print all sub nodes of the current user document node if it represents a folder
            if (userDocumentNode.IsSubFolder)
            {
                PrintUserDocumentNodes(apiClient, userDocumentFolder,
                    Path.Combine(relativePath, userDocumentNode.Name), indentationDepth + 1);
            }
        }
    }
}
  

See Also

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com