Skip to main content Skip to complementary content

GetSourceDocumentFolders Method

Overloads

GetSourceDocumentFolders(Guid, DocumentFolderScope)

Gets all source document folders for the QlikView Distribution Service with the specified ID.

GetSourceDocumentFolders(Guid, DocumentFolderScope)

Gets all source document folders for the QlikView Distribution Service with the specified ID.

Declaration

      List<DocumentFolder> GetSourceDocumentFolders(Guid qdsID, DocumentFolderScope scope)
    

Parameters

Type Name Description
System.Guid qdsID

The ID of the QlikView Distribution Service for which to retrieve source document folders.

DocumentFolderScope scope

The scope of the source document folders to retrieve.

Returns

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

All source document folders with the specified scope for the QlikView Distribution Service with the specified ID.

Remarks

Only source 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 Distribution Service, all its source document folders and nodes. The GetSourceDocumentNodes(Guid, Guid, String) method is called recursively to print sub folders and source 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.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 QDS services
            List<ServiceInfo> qdsServices = apiClient.GetServices(ServiceTypes.QlikViewDistributionService);
            if (qdsServices.Count > 0)
            {
                // retrieve all source document folders for the first QDS in the list
                Console.WriteLine("The " + qdsServices[0].Name
                    + " contains has following source document file structure:" + Environment.NewLine);
                List<DocumentFolder> sourceDocumentsFolders = apiClient.GetSourceDocumentFolders(qdsServices[0].ID,
                    DocumentFolderScope.General | DocumentFolderScope.Services);
                // loop through all source document folders
                foreach (DocumentFolder sourceDocumentFolder in sourceDocumentsFolders.OrderBy(x => x.General.Path))
                {
                    // print the names of all source document folders, prefix with [R] for root folders
                    Console.WriteLine("[R] " + sourceDocumentFolder.General.Path);
                    // print all sub nodes of the current source document folder
                    PrintSourceDocumentNodes(apiClient, sourceDocumentFolder, string.Empty, 1);
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("An exception occurred: " + ex.Message);
        }
        // wait for user to press any key
        Console.ReadKey();
    }

    static void PrintSourceDocumentNodes(IQMS apiClient, DocumentFolder sourceDocumentFolder,
        string relativePath, int indentationDepth)
    {
        // retrieve all source document nodes of the given folder and under the specified relative path
        List<DocumentNode> sourceDocumentNodes = apiClient.GetSourceDocumentNodes(sourceDocumentFolder.Services.QDSID,
            sourceDocumentFolder.ID, relativePath);
        // loop through all current source document nodes
        foreach (DocumentNode sourceDocumentNode in sourceDocumentNodes
            .OrderByDescending(x => x.IsSubFolder).ThenBy(x => x.Name))
        {
            // print the names of all source document nodes, indent and
            // prefix with [F] for folders and [D] for documents
            string indentation = new string(' ', indentationDepth * 3);
            string nodePrefix = (sourceDocumentNode.IsSubFolder ? "[F]" : "[D]");
            Console.WriteLine(indentation + nodePrefix + " " + sourceDocumentNode.Name);
            // print all sub nodes of the current source document node if it represents a folder
            if (sourceDocumentNode.IsSubFolder)
            {
                PrintSourceDocumentNodes(apiClient, sourceDocumentFolder,
                    relativePath + "\\" + sourceDocumentNode.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