Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
SKum2PL
Contributor
Contributor

Custom Extension doesn't fetch a value to the variables

Hi,

I've Qlik sense Cloud. I created a custom extension in the Dev Hub through extension creator to create a variable which gets its value from a formula. Custom extension is also visible in the custom objects under extension tab.

define([], function() {
  'use strict';

  return {
    paint: function($element, layout) {
      var app = qlik.currApp();

      app.createCube({
        qDimensions: [],
        qMeasures: [{
          qDef: {
            qDef: "=Sum({<Year={'2023'}, Scenario ={'Forecast'}, Data_type ={'Costs'}>}(Amount/1000))",
            qLabel: "TotalHQDC"
          }
        }],
        qInitialDataFetch: [{
          qTop: 0,
          qLeft: 0,
          qHeight: 1,
          qWidth: 1
        }]
      }, function(reply) {
        var totalHQDC = reply.qHyperCube.qDataPages[0].qMatrix[0][0].qNum;
        app.variable.setStringValue('vTotalHQDC', totalHQDC.toString());
      });
    }
  };
});

 

in the load editor, I have added following code

LET vTotalHQDCExtension = if(isnull($(vTotalHQDC)), 'TotalHQDC', $(vTotalHQDC));
LET vTotalHQDC = Num($(#=app.variable.get("TotalHQDC").value));

 

it basically check if the variable vTotalHQDC is null or not, and if it is null then set the vTotalHQDCExtension variable to "TotalHQDC". The second LET statement then converts the value of the TotalHQDC variable to a number using the Num function.

then I added a text in a sheet and added fx = $(vTotalHQDC)

I am getting no error but value is coming as zero in the text. even if I used KPI object then value returns as 0. so not sure where I'm going wrong. is it something to do with my limited access in Qlik cloud or there is flaw in this entire approach?

Labels (6)
0 Replies