Skip to content

Get sheets from an app

With qlik-embed, you can access the metadata of a Qlik Analytics (Sense) application, including, but not limited to, obtaining a list of sheets and adding them to a dropdown list element.

<script>
  //qlik-embed connection script to add qlik-embed web component
</script>
<body>
  <div>
    <select id="sheetdrop" name="SheetList">
    </select>
  </div>
  <div>
    <qlik-embed
      id="appSheets"
      ui="object"
      app-id="<APP_ID_FROM_QLIK_ANALYTICS>"
      object-id="<OBJECT_ID_OF_SHEET_IN_APP>"
    ></qlik-embed>  
  </div>
</body>
<script type="module">
  const embeddedObject = document.getElementById("appSheets");
  const refApi = await embeddedObject.getRefApi();
  const doc = await refApi.getDoc();
  const appSheetList = await doc.getSheetList();

  //add the sheet references to a dropdown list
  let dd = document.getElementById('sheetdrop');
  dd.length = 0;
  let defaultOption = document.createElement('option');
  defaultOption.text = "Select a sheet to navigate to";
  dd.add(defaultOption);
  dd.selectedIndex=0;

  let option;
  for (let i=0;i<appSheetList.length; i++) {
    option = document.createElement('option');
    option.text = appSheetList[i].qMeta.title;
    option.value = appSheetList[i].qMeta.id;
    dd.add(option);
  }

  //add a listener to change the object-id property in the qlik-embed element
  dd.addEventListener("change", function() {
    if (dd.selectedIndex > 0)
    {
      let selOption = dd.options[dd.selectedIndex];
      console.log(selOption.value);
      embeddedObject.setAttribute('object-id', selOption.value);
    }
  });
</script>

Want to explore more qlik-embed? Explore all qlik-embed UIs and params.

ON THIS PAGE

Was this page helpful?