qlikviewqliksense

How can i get a Qlik app layout as XML/JSON File?


What is the simplest way to view the structure/layout of my Qlik dashboards in the form of XML or JSON files in Qlik Sense Desktop? So it should contain detailed informaions about visualizations & styles.

Is building a (Python) script to access information via the Qlik Engine JSON API the right approach?

Update 1 current Code

(async () => {
  const { docMixin } = await import("enigma-mixin");
  const fs = require('fs');
  const enigma = require('enigma.js');
  const WebSocket = require('ws');
  const schema = require('enigma.js/schemas/12.612.0.json');

  // create a new session:
  const session = enigma.create({
      schema,
      mixins: [docMixin],
      url: 'ws://localhost:9076/app/engineData',
      createSocket: url => new WebSocket(url),
  });

  async function run() {
      const global = await session.open()

      // change to your appId
      const doc = await global.openDoc("My_App")

      const entities = await doc.mUnbuild()

      await session.close()
  }

  await run();
})();

Output

const entities = await doc.mUnbuild()
                                 
TypeError: doc.mUnbuild is not a function

Edit 2 - follow up question I am now able to extract the names of fields and measures from the visualizations. I am currently looking for a way to automatically determine from which table these names originate. This presents some difficulties, as fields/measures in the script, for example, may be renamed or calculated...

A simple example for illustration: A chart has the dimension 'Country.' 'Country' was renamed from 'State' in the script. This means that the 'Country' field does not exist in the database.

My current approach: I extract the script from the JSON, pass a list of the extracted names from the visualization to an LLM (LookML Model), and try to reconstruct the origin in the database. Unfortunately, this does not work so well. Do you have a suggestion for an alternative approach?


Solution

  • For QlikSense:

    For QlikView:

    Tthis functionality exists into QV itself. Have a look at this tutorial how to create xml files with the app components

    Update - Adding enigma-mixin example

    import fs from "fs"
    import WebSocket from "ws";
    import enigma from "enigma.js";
    import { docMixin } from "enigma-mixin";
    
    const schema = JSON.parse(fs.readFileSync("./node_modules/enigma.js/schemas/12.612.0.json"));
    
    const session = enigma.create({
        schema,
        mixins: [...docMixin],
        url: "ws://127.0.0.1:4848/app/engineData",
        createSocket: (url) => new WebSocket(url),
    });
    
    async function run() {
        const global = await session.open()
    
        // change to your appId
        const doc = await global.openDoc("SOME-APP-ID-HERE")
    
        const entities = await doc.mUnbuild()
    
        await session.close()
    }
    
    run()
    

    In the script above enities variable will have the following content:

    mUnbuild result